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
精彩评论