tags:

views:

909

answers:

3

i'm using the mshtml dll to develop a helper to ie, i'm trying to get the position of an htmll element, i have an object with type of HTMLAnchorElementClass when i'm trying to get his style.posTop value i get a null ref exception

is there a better way to do it?

maybe other cast?

please help

+1  A: 

Try

element.offsetTop
element.offsetLeft
Steerpike
10x for your help
Chen Kinnrot
sorry not working
Chen Kinnrot
+2  A: 

Here's an example I found (the way you're obtaining a reference to your element object is probably different, but take a look at this anyway:

Element = <however your get your element>;

//--- Determine real element size and position relative to the main page.
int ElementLeft = Element.offsetLeft;
int ElementTop = Element.offsetTop;
mshtml.IHTMLElement TmpElem = Element.offsetParent;
while (TmpElem != null)
{
     ElementLeft = ElementLeft + TmpElem.offsetLeft;
     ElementTop = ElementTop + TmpElem.offsetTop;
     TmpElem = TmpElem.offsetParent;
}
Cory Larson
sorry not working
Chen Kinnrot
A: 

This method couldn't work with this link http://s1.webstarts.com/VacationHome/rates.html. With the item
High season:

The absolute top is 526 and with the item : $160 / nt or £95 / nt
The absolute top is 545. The distance btw them is too large

binhvu