Javascript - Track mouse position

后端 未结 11 1293
谎友^
谎友^ 2020-11-22 03:13

I am hoping to track the position of the mouse cursor, periodically every t mseconds. So essentially, when a page loads - this tracker should start and for (say) every 100 m

11条回答
  •  你的背包
    2020-11-22 04:02

    Here's a solution, based on jQuery and a mouse event listener (which is far better than a regular polling) on the body:

    $("body").mousemove(function(e) {
        document.Form1.posx.value = e.pageX;
        document.Form1.posy.value = e.pageY;
    })
    

提交回复
热议问题