📜  Javascript 跟踪鼠标指针 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:03.989000             🧑  作者: Mango

代码示例1
var pointerX = -1;
var pointerY = -1;
document.onmousemove = function(event) {
    pointerX = event.pageX;
    pointerY = event.pageY;
}
setInterval(pointerCheck, 1000);
function pointerCheck() {
    console.log('Cursor at: '+pointerX+', '+pointerY);
}