[Javascript] True element coordinates on mouseevent.

Håkan Magnusson hakan at backbase.com
Fri Nov 7 05:19:34 CST 2003


Hi Peter!

Thanks, but you missed an essential part of my question. I've allready 
browsed through quirksmode for the answer, of course. :)

> (the exact coordinates
> of the mouse pointer on the element it's currently hovering,
> [event.]layerX/layerY (only absolutely position/Mozilla) or
> [event.]offsetX/offsetY(IE/Safari only))

Element, not document.

> That was in Netscape 4.

Not for the coordinates on the ELEMENT I'm hovering. But I worked it 
out, by iterating up through the parents of the target element and 
calculating the elements exakt x/y position, regardless of parental 
positioning, then subtracting that x/y position from the mouse position.

It's ugly, but it works.

Håkan




More information about the Javascript mailing list