Note that the code below may fail under various conditions, such as IE
running in strict mode, or if there are scrollable elements such as DIVs
within the page.
See
http://www.mattkruse.com/javascript/...sitionTest.php for my
attempt at a more generalized position-finding function. It's not complete
yet, but is more reliable than the method used by most (like the one below).
michael elias wrote:
Sure:
function measureLeft(oElement){
var iLeft = oElement.offsetLeft;
var oParent = oElement.offsetParent;
while(oParent.nodeName != 'BODY'){
iLeft += oParent.offsetLeft;
oParent = oParent.offsetParent;
}
return iLeft;
}
function measureTop(oElement){
var iTop = oElement.offsetTop;
var oParent = oElement.offsetParent;
while(oParent.nodeName != 'BODY'){
iTop += oParent.offsetTop;
oParent = oParent.offsetParent;
}
return iTop;
}
(top-posted for easier reading)
--
Matt Kruse
http://www.JavascriptToolbox.com http://www.AjaxToolbox.com