【发布时间】:2011-11-07 15:11:54
【问题描述】:
我正在尝试将 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){...};
编辑:
window.onmousemove = function(event){...}; // doesn't work either
EDIT2:我需要整个身体都响应,而不仅仅是嵌套元素。
所有这些都有效,但在 IE 中没有。
我该如何解决这个问题?
【问题讨论】:
-
你试过了吗:
window.onmousemove = ...? -
IE的版本是9,我现在用
window.onmousemove试试(不是本地电脑,需要一些时间) -
如果你将它绑定在身体上(无论出于何种原因),身体实际上有大小吗?我在这里进行了大胆的猜测,但是您的身体是否只有很小的高度,而您可能期望可见的窗口就是身体?
-
Sime Vidas:不,它没有(?!——奇怪……)里面的一些元素。
-
@Sime Vidas,再次:对不起,现在我明白它的作用了。但是,我需要整个身体都在聆听,而不仅仅是其中的文本元素。
标签: javascript internet-explorer events bind mousemove