var xPos;
var yPos;
document.onmousemove = mouseMove;
function mouseMove(ev) {
ev = ev window.event;
var mousePos = mouseCoords(ev);
xPos = mousePos.x;
yPos = mousePos.y;
}
함수 mouseCoords(ev) {
if (ev.pageX ev.pageY) {
return { x: ev.pageX, y: ev.pageY };
}
반환 {
x:ev.clientX document.body.scrollLeft document.documentElement.scrollLeft,
y:ev.clientY document.body.scrollTop document.documentElement.scrollTop
} ;
}