获取DOM元素的屏幕坐标 [英] Get screen coordinates of DOM element

查看:216
本文介绍了获取DOM元素的屏幕坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以以某种方式获得DOM对象的精确屏幕坐标(相对于屏幕的左上角)。通过NPAPI\FireBreath或JavaScript。 (需要这个插件,我用FireBreath写

Can I somehow get precise screen coordinates (relative to top left corner of the screen) of a DOM object. Through NPAPI\FireBreath or JavaScript. (Need this for plugin, that I'm writing with FireBreath)

推荐答案

你将光标移动到页面,并进行点击事件(找到窗口,然后GetWindowRect,计算一个可视位置),然后可以捕获事件,记录clientX和clientY。通过这种方式,您可以在两个不同的坐标系之间建立桥梁。

you move cursor to somewhere of the page ,and make a click event.(find the window,then GetWindowRect ,caculate a sutable position) then you can catch the event,record clientX and clientY. By this ,you build a bridge between two different coordinate system.

这篇关于获取DOM元素的屏幕坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆