开发者

How can I calculate the position of a DOM element from Google Chrome content scripts

I am writing a chrome extension and from the content script I want to calculate the absolute position of a DOM element. But from within content script, if i try to access offsetHeight, offsetWidth, offsetTop, offsetParent, etc, I get null. I开发者_StackOverflow中文版 guess content scripts don't have access to those DOM properties.

Is there a way/workaround, i can find those properties?


It should work great, how are you accessing it?

// Should be something like this:
var height = document.getElementById('mydiv').offsetHeight;

https://developer.mozilla.org/En/DOM/Element.offsetHeight

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜