Closed Thread Icon

Preserved Topic: x,y coordinates of an object Pages that link to <a href="https://ozoneasylum.com/backlink?for=18161" title="Pages that link to Preserved Topic: x,y coordinates of an object" rel="nofollow" >Preserved Topic: x,y coordinates of an object\

 
Author Thread
maninacan
Paranoid (IV) Inmate

From: Seattle, WA, USA
Insane since: Oct 2001

posted posted 03-08-2002 02:22

anyone know how to do this? BTW the object is a div tag that is relativley positioned, and I want to figure out the absolute x and y coordinates of it. Please help as soon as you can, it needs to be soon.

http://www.kewlster.com

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 03-08-2002 08:01

IE/Mozilla:
x = document.getElementById("layerName").offsetLeft;
y = document.getElementById("layerName").offsetTop;

NN4:
x = document.layers["layerName"].pageX;
y = document.layers["layerName"].pageY;


bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 03-08-2002 19:37

I seem to remember having problems with this in NN4 if you scroll the page. I can't remember the value exactly but I think it's like .document.pageScrollX and Y that you need to use (either add or subtract) if you're trying to get this position after someone has scrolled the page.

Sorry not on my main box right now but someone should be able to help



.:[ The Tao of Steve ]:.
Be Desireless
Be Excellent
Be Gone
...................................

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 03-08-2002 21:21

document.layers["layerName"].pageXOffset;
document.layers["layerName"].pageYOffset;


maninacan
Paranoid (IV) Inmate

From: Seattle, WA, USA
Insane since: Oct 2001

posted posted 03-13-2002 03:31

it's not working. I just tested it in IE6 with the following code:

...
<SCRIPT>
function getcoords(name){
x = document.getElementById(name).offsetLeft
y = document.getElementById(name).offsetTop

alert (x + " " + y);
}
</SCRIPT>
...
<BODY onload="getcoords('navbar');">
...
<DIV NAME="navbar" CLASS="bar">
...
</DIV>

any reason this shouldn't work for IE6? Cause it's not.


http://www.kewlster.com

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 03-13-2002 07:15

Instead of using NAME parameter (which is invalid), you should use ID parameter to define a name of your layer...

<DIV ID="navbar" CLASS="bar">
...
</DIV>


maninacan
Paranoid (IV) Inmate

From: Seattle, WA, USA
Insane since: Oct 2001

posted posted 03-14-2002 07:02

muchas gracias!!!!!!!!!!! That made a big difference, as in it worked. I never knew there was a difference between NAME and ID, that's probably where I've had problems before. Once again thank you very much I couldn't figure it out.

http://www.kewlster.com

« BackwardsOnwards »

Show Forum Drop Down Menu