Connecting Tech Pros Worldwide Forums | Help | Site Map

Mouse over

egebamyasi
Guest
 
Posts: n/a
#1: Jan 25 '07
I have been trying to find the mouse coords when I move the pointer
over a div/image/etc... When I try e.clientX, e.clientY I retrieve the
mouse coords relative to the browser window. This is okay but
unfortunately when I scroll down the contents change position while the
coords stay the same. Is there any way around this?


Ivo
Guest
 
Posts: n/a
#2: Jan 25 '07

re: Mouse over


"egebamyasi" <ashley.hales@gmail.comschreef
Quote:
>I have been trying to find the mouse coords when I move the pointer
over a div/image/etc... When I try e.clientX, e.clientY I retrieve the
mouse coords relative to the browser window. This is okay but
unfortunately when I scroll down the contents change position while the
coords stay the same. Is there any way around this?
So measure the amount that has been scrolled and substract that from the
mousepositions as found. It is unfortunate but will come as no big surprise
that browsers report this in different properties. Some use
document.pageXOffset and document.pageYOffset but IE cs. put the numbers in
document.scrollLeft and document.scrollTop. To see if either a number use
the typeof operator instead of just checking the value because the value may
be 0 (zero).
HTH
Ivo
http://4umi.com/web/javascript/mouseposition.htm


Closed Thread