Closed Thread Icon

Topic awaiting preservation: Finding the absolute position of a staticly placed object. (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=8863" title="Pages that link to Topic awaiting preservation: Finding the absolute position of a staticly placed object. (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Finding the absolute position of a staticly placed object. <span class="small">(Page 1 of 1)</span>\

 
Maskkkk
Paranoid (IV) Inmate

From: Willaimsport, PA, US of A the hole in the Ozone
Insane since: Mar 2002

posted posted 09-22-2003 21:33

Is there anyway to find the absolute position of a statically placed object? For instance if I have an image in a table, and I want to place an absolutly positioned image over top of that image, is there anyway I can first find out the absolute location of the statically placed object?



- Biggie

- Face the Present
- AIM: MASKKKK

01001101011000010111001101101011011010110110101101101011

rickindy
Nervous Wreck (II) Inmate

From: Indianapolis, In USA
Insane since: Jan 2002

posted posted 09-23-2003 14:05

Getting the left and top coordinates of anything inside a table can be a little tricky.
Actually, that's true of gettin the left and top of anything that's inside something else.
Here's a couple of functions I have found useful.
All you have to do is pass in the element that you are working with and it they will return the page left or top of it.
In your case, pass it the image you want the coordinates for.
For example document.images[image_name]

function getObjectLeft(obj){
left = obj.offsetLeft;
el = obj.offsetParent;
while(el != null){
left += el.offsetLeft;
el = el.offsetParent;
}
return left;
}

function getObjectTop(obj){
realY = obj.offsetTop;
el = obj.offsetParent;
while(el != null){
realY += el.offsetTop;
el = el.offsetParent;
}
return realY;
}

HTH


Few problems in life can't be solved by chocolate

« BackwardsOnwards »

Show Forum Drop Down Menu