"egebamyasi" <as**********@gmail.comschreef
>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