开发者

JavaScript: elementFromPoint(x,y)

Hey guys, I'm writing a Firefox plugin and using the following function:

var obj = page.elementFromPoint(x,y); //x,y are the mouse coordinates

However this function returns the topmost element which lies under the given point. This isn't good enough for me, I need the most inner element which lies under the given point. Does anyone know how to do it?

Thanks开发者_JS百科


Gecko and WebKit support the style pointer-events: none; to prevent pointer events on the element obscuring the one you want to find, but generally you can only manually search the DOM tree. Or set display: none; to the elements you don't want to get before you use elementFromPoint, if that is possible in your setup.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜