Claus Topholt
Posts: 1
Joined: 2019-12-09
|
I have an onClick handler for a context menu, so users can right-click any page element. Now I'd like to get the position of the element. It seems I can get the size (clientWidth and clientHeight) but how do I get the position on the page?
Edit: Figured it out:
var element = (IHTMLElement)htmlElement;
var x = 0;
var y = 0;
while(element.parentElement != null)
{
x += element.offsetLeft;
y += element.offsetTop;
element = element.parentElement;
}
|
|
Andrei Smolin
Add-in Express team
Posts: 19103
Joined: 2006-05-11
|
Hello Claus,
Thank you for posting your solution!
Andrei Smolin
Add-in Express Team Leader |
|