我在鼠標後面有一個拖尾對象。 當鼠標離開窗口時,我想隱藏它。 這可以在其他瀏覽器中正常工作,,但甚至不會觸發IE8>中的事件。 <Javascript:鼠標事件不會在IE中觸發8
如果只有我能觸發它,那麼猜測它會工作正常。
function mouseport(e){
//alert('event triggered');
if (document.all) { //IF IE
mouseX = event.clientX;
mouseY = event.clientY;
} else {
mouseX = (window.Event) ? e.clientX : event.clientX;
mouseY = (window.Event) ? e.clientX : event.clientY;
}
if ((mouseY > 0 && mouseY < window.innerHeight)
&& (mouseX > 0 && mouseX < window.innerWidth)){
return false;
}else{
if (follow) hidett() //that's my hide function
}
}
// for IE compatability
if (!window.addEventListener) {
window.attachEvent("mouseout", mouseport);
}
else {
window.addEventListener("mouseout", mouseport, false);
}
if (window.Event) {
if (window.captureEvents) { //doesn't run if IE
document.captureEvents(Event.MOUSEOUT);
}
}
請幫忙找,我犯了一個錯誤,它不會觸發...
使用JS庫如jQuery處理平臺的不兼容性爲您服務。 – dbkaplun
謝謝,但我沒有要求jquery,請看標題... – Anonymous