/ Published in: JavaScript

Snagged from pp]{
It's relative to document, not the visible area in the window.
It's relative to document, not the visible area in the window.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function handleEvent(e) { if (!e) var e = window.event; var posx = 0; var posy = 0; if (!e) var e = window.event; if (e.pageX || e.pageY) { posx = e.pageX; posy = e.pageY; } else if (e.clientX || e.clientY) { posx = e.clientX + document.body.scrollLeft; posy = e.clientY + document.body.scrollTop; } // posx and posy contain // the mouse position relative to the document // Do something with this information }
URL: http://evolt.org/article/Mission_Impossible_mouse_position/17/23335/index.html
Comments
