這是一個部分代碼,而不是完整版本。如何在IE中分離事件6 7 8 9使用JavaScript
我有一個突出顯示特定html元素的熒光筆,當時mouse hovers
。
我也有一個click event and listener
。
我的問題是:highlighter event/listener
不分離使用Internet Explorer
當V6 V7 V8 V9
我到底做錯了什麼?
這是怎麼附上事件,並啓動事件偵聽器:
if (document.body.addEventListener) {
//alert(11);
document.body.addEventListener('mousemove', handler, false);
} else if (document.body.attachEvent) {
//alert(12);
var ff=function(e) {
return handler(e || window.event);
};
//alert(ff);
document.body.attachEvent('onmousemove', ff);
} else {
//alert(13);
document.body.onmousemove = handler;
}
這是我如何停止的OnMouseMove /鼠標事件/監聽器:
if (document.body.removeEventListener) {
document.body.removeEventListener('mousemove', handler, false);
} else if (document.body.detachEvent) {
document.body.detachEvent('onmousemove', function(e) {
return handler(e || window.event);
});
} else {
document.body.removeAttribute("onmousemove");
}
我這是怎麼停止onclick/click event/listener:
if (document.body.removeEventListener) {
document.body.removeEventListener('click', ClosetAffairHighlighter.highlightClick, false);
} else if (document.body.detachEvent) {
document.body.detachEvent('onclick', ClosetAffairHighlighter.highlightClick);
} else {
document.body.removeAttribute("onclick");
}
大鼠,這拉票鏈接不再有效,是否有替代產品或鏈接那可以提到? – danjah
@Danjah感謝提醒,這個要點:https://gist.github.com/objectfoo/4144898是一個代碼庫。 –