IE将mouse绑定到body

ari*_*rik 2 javascript events internet-explorer bind mousemove

我试图将mousemove事件绑定到正文.到目前为止我的尝试:

$('html, body').mousemove(function(event){...});

$('html, body')[0].onmousemove= function(event){...};

$('body').bind('mousemove', function(event){...});

document.onmousemove = function(event){...};

document.getElementsByTagName('body')[0].onmousemove = function(event){...};
Run Code Online (Sandbox Code Playgroud)

编辑:

window.onmousemove = function(event){...}; // doesn't work either
Run Code Online (Sandbox Code Playgroud)

编辑2:我需要全身反应,而不仅仅是嵌套元素.

所有这些都有效,但在IE中没有.

我怎么解决这个问题?

Esa*_*ija 6

你不希望它在体内,因为身体不一定是整页.

$( document ).mousemove( function () {

});
Run Code Online (Sandbox Code Playgroud)

jsfiddle:http://jsfiddle.net/uDfPj/

或者没有jQuery:

document.documentElement.onmousemove = function(){};
Run Code Online (Sandbox Code Playgroud)