Hello.
I once made a site that relied heavily on the repositioning of dynamically sized elements on the page, so it was important for me to have some code that could work our the browser computed width and height and position (x,y coordinates) of any element on the page. And we came up with this code, which was a mixture of things we found on the web:
// Functions to work out computed width, height, and absolute position on the page
function getComputedHeight(o){
return navigator.appName=="Microsoft Internet Explorer"?parseInt(o.offsetHeight):parseInt(document.defaultView.getComputedStyle(o,"").getPropertyValue("height").split("px")[0]);
}
function getComputedWidth(o){
return navigator.appName=="Microsoft Internet Explorer"?parseInt(o.offsetWidth):parseInt(document.defaultView.getComputedStyle(o,"").getPropertyValue("width").split("px")[0]);
}
function getPos(o){
var l=t=0;
if(o.offsetParent){
do{ l+=o.offsetLeft; t+=o.offsetTop; } while(o=o.offsetParent);
return [parseInt(l),parseInt(t)];
}
}
It should be quite simple to understand - you basically pass the element's DOM object to the function, and it will return what you need... I hope!