标签:
用JS的方式获取就要用getBoundingClientRect方法,like this:
window.frames[‘mainframe‘].document.getElementById(‘Img‘).getBoundingClientRect().left;
但是JS时灵时不灵,下面就是不用JS的方法:
public Point GetOffset(HtmlElement el) { //get element pos Point pos = new Point(el.OffsetRectangle.Left, el.OffsetRectangle.Top); //get the parents pos HtmlElement tempEl = el.OffsetParent; while (tempEl != null) { pos.X += tempEl.OffsetRectangle.Left; pos.Y += tempEl.OffsetRectangle.Top; tempEl = tempEl.OffsetParent; } return pos; } var point = GetOffset(element); var x = point.X; var y = point.Y;
C#如何获得webbrowser网页里某元素所占用的位置坐标
标签:
原文地址:http://www.cnblogs.com/Ajuice/p/5243065.html