最佳答案
我想在 Javascript 中得到一个对象在页面上的绝对 x,y 位置,我该怎么做呢?
我尝试了 obj.offsetTop
和 obj.offsetLeft
,但它们只给出相对于父元素的位置。我想我可以循环并添加父类的偏移量,和它的父类的偏移量,以此类推,直到我得到没有父类的对象,但似乎应该有更好的方法。谷歌搜索没有得到什么结果,即使这样,网站搜索也没有找到任何东西。
另外,我不能使用 jQuery。