function mouseMove(ev) {
Ev = ev || window.event;
var mousePos = mouseCoords(ev);
console.log('点击位置: (x: ' + mousePos.x + ' y: ' + mousePos.y + ')');
}
function mouseCoords(ev) {
if (ev.pageX || ev.pageY) {
return {x: ev.pageX, y: ev.pageY};
}
return {
x: ev.clientX + document.body.scrollLeft - document.body.clientLeft,
y: ev.clientY + document.body.scrollTop - document.body.clientTop
};
}
document.onclick = mouseMove;
网友评论