Find the coordinates of the mouse cursor using JavaScript
From CodeCodex
[edit] Implementations
[edit] JavaScript
When called, this script sets the document variables X and Y to the location of the mouse relative to the uppermost left pixel of the webpage.
var IE = document.all?true:false;
if (!IE) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getMouseXY;
var X = 0;
var Y = 0;
function getMouseXY(e) {
if (IE) { // grab the x-y pos.s if browser is IE
X = event.clientX + document.body.scrollLeft;
Y = event.clientY + document.body.scrollTop;
} else { // grab the x-y pos.s if browser is NS
X = e.pageX;
Y = e.pageY;
}
if (X < 0){ X = 0; }
if (Y < 0){ Y = 0; }
return true;
}

