firebug - get absolute coordinates -


i need absolute coordinates (left , top relative beginning of document) of dom element inspected firebug regardless depth of dom tree. there such plugin?

you don't need plugin in fact, chunk of javascript + knowledge of firebug internals.

you can find in this article how absolute coords of dom element. each dom element has properties .offsetleft .offsettop .offsetparent define position regarding other dom element (the offsetparent). element on top of hierarchy has offsetparent = null. can traverse elements , offsetparents hierarchy find absolute coords, given element.

the code copied page:

var findpos = function findpos(obj) {    var curleft = curtop = 0;    if (obj.offsetparent) {       {       curleft += obj.offsetleft;       curtop += obj.offsettop;       } while (obj = obj.offsetparent);       return [curleft,curtop];    } } 

(paste in firebug, , have findpos function available in console).

for majority of simplest cases, have offsetparent = <body> has 0 offsets (like in screenshots) don't need add offsetleft , offsettop. if relative positionings take place, must traverse parents.

when select element in firebug, it's available $0 in firebug console.

so, after mixing 2 things, can issue commands in screenshot:

firebug - finding absolute coords of node

to absolute coords of element.

the script i've pasted above should work in huge majority of occasions. may want read this post bit more robust function.


Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -