topical media & game development
#javascript-code-15-getX.js / js
// Find the horizontal position of the cursor
function getX(e) {
// Normalize the event object
e = e || window.event;
// Check for the non-IE position, then the IE position, and finally return 0
return e.pageX || e.clientX + document.body.scrollLeft || 0;
}
// Find the vertical position of the cursor
function getY(e) {
// Normalize the event object
e = e || window.event;
// Check for the non-IE position, then the IE position, and finally return 0
return e.pageY || e.clientY + document.body.scrollTop || 0;
}
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.