Pondering the eternal question of "Hobnobs or Rich Tea?",
un**********@mchsi.com finally proclaimed:
I have a table with a <DIV> in it and would like to get the left
property of the <DIV>. It comes back 0. I would like to get the the
position relative to the screen (like 354). Is this possible? If so
could you please point me in the right direction?
I found the following functions somewhere a while ago:
/*
Function to find the x position of the top left corner of
a given object
*/
function findPosX(obj) {
var curleft = 0;
if (obj.offsetParent) {
while (obj.offsetParent) {
curleft += obj.offsetLeft
obj = obj.offsetParent;
}
}
else if (obj.x)
curleft += obj.x;
return curleft;
}
/*
Function to find the y position of the top left corner of
a given object
*/
function findPosY(obj) {
var curtop = 0;
if (obj.offsetParent) {
while (obj.offsetParent) {
curtop += obj.offsetTop
obj = obj.offsetParent;
}
}
else if (obj.y)
curtop += obj.y;
return curtop;
}
I'm sure they can be improved upon, but they've done the job for me on
many occasions!
--
Dylan Parry
http://webpageworkshop.co.uk -- FREE Web tutorials and references