Show mouse position in DIV
Posted on 2006-04-20
I have set an onmousemove event on a DIV in which I want to locate
the position of the mouse cursor (relative to the top left of the DIV). I am using
event.offsetX and event.offsetY to get the position of the mouse within the
DIV element. This works great, as long as there is no object inside the DIV. When I
add an image in the DIV, as soon as the cursor passes over that image,
offsetX and Y become 0 again.
How can I get the event.offsetX and event.offsetY to always be reported in
relation to my parent DIV element?