Skip to content

Instantly share code, notes, and snippets.

@ioseb
Created May 5, 2009 21:18
Show Gist options
  • Save ioseb/107201 to your computer and use it in GitHub Desktop.
Save ioseb/107201 to your computer and use it in GitHub Desktop.
function getMouseXY(e) {
var x, y, e = window.event || e;
if (e.clientX) {
x = e.clientX + Math.max(
document.documentElement.scrollLeft,
document.body.scrollLeft
);
y = e.clientY + Math.max(
document.documentElement.scrollTop,
document.body.scrollTop
);
} else if (e.pageX && typeof(e.pageX) == 'number') {
x = e.pageX;
y = e.pageY;
}
return {x: x, y: y};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment