Closed Thread Icon

Topic awaiting preservation: retrieving absolute position from static element? (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=9031" title="Pages that link to Topic awaiting preservation: retrieving absolute position from static element? (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: retrieving absolute position from static element? <span class="small">(Page 1 of 1)</span>\

 
haoest
Obsessive-Compulsive (I) Inmate

From:
Insane since: Dec 2002

posted posted 02-22-2004 03:36

Hey:

I have a button, whose positioning (including all its parents) is static.
I am wondering if there's anyways I can retrief its coordinates, or if there's any tricks
i can use to get its x,y so that I can place an absolutely positioned image next to it.

thanks.



Cameron
Bipolar (III) Inmate

From: Brisbane
Insane since: Jan 2003

posted posted 02-24-2004 15:48

You'll want to use a recursive function to loop back through each parent element adding up it's offsetTop or offsetLeft values.

Remember, the offset* values aren'y style object properties, their properties of the element object ...

bad:
pixels_up_to_parent_boundry = document.getElementById("foo").style.offsetTop;

good:
pixels_up_to_parent_boundry = document.getElementById("foo").offsetTop;



[This message has been edited by Cameron (edited 02-24-2004).]

« BackwardsOnwards »

Show Forum Drop Down Menu