Reputation: 21015
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
Upvotes: 0
Views: 2729
Reputation: 99
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
Upvotes: 0
Reputation: 107616
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;
}
Upvotes: 2