/ Published in: JavaScript
URL: http://ajaxian.com/archives/javascript-tip-cross-browser-cursor-positioning
Nice little snippet i found on Ajaxian, finds the position of the mouse cursor when it is fired.
Expand |
Embed | Plain Text
function getPosition(e) { e = e || window.event; var cursor = {x:0, y:0}; if (e.pageX || e.pageY) { cursor.x = e.pageX; cursor.y = e.pageY; } else { cursor.x = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft; cursor.y = e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop; } return cursor; }
Comments
Subscribe to comments
You need to login to post a comment.

Interesting how you and Dustin Diaz made the exact same function, isn't it? http://www.dustindiaz.com/getelementsbyclass/
just ignore my comment, it was for another someone :D sorry