We Recommend

Pro JavaScript Techniques Pro JavaScript Techniques
Pro JavaScript Techniques is the ultimate JavaScript book for the modern web developer. It provides everything you need to know about modern JavaScript, and shows what JavaScript can do for your web sites. This book doesn't waste any time looking at things you already know, like basic syntax and structures.


Posted By

szsk on 08/02/06


Tagged

javascript event DOM mouse


Versions (?)


Who likes this?

13 people have marked this snippet as a favorite

luman
meth
hides
hxseven
noah
fael
vali29
Winkyboy
yetanother
SpinZ
kcmr
wizard04
hans


getMousePosition


Published in: JavaScript 


  1. function getMouseX( e ) {
  2. return e.pageX
  3. || ( e.clientX + ( document.documentElement.scrollLeft
  4. || document.body.scrollLeft ) );
  5. }
  6. function getMouseY( e ) {
  7. return e.pageY
  8. || ( e.clientY + ( document.documentElement.scrollTop
  9. || document.body.scrollTop ) );
  10. }

Report this snippet 

You need to login to post a comment.