0

我在鼠标之后有一个尾随对象。当鼠标离开窗口时,我想隐藏它。这在其他浏览器中可以正常工作,但甚至不会触发 IE8 中的事件>.<

如果我能触发它,那么我猜它会正常工作。

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);
            }
        }

请帮助找出我在哪里犯了它不会触发的错误......

4

2 回答 2

1
window.attachEvent("mouseout", mouseport);

应该

document.attachEvent("onmouseout", mouseport);

http://msdn.microsoft.com/en-us/library/ie/ms536343(v=vs.85).aspx

于 2012-06-15T00:11:40.980 回答
0

尝试添加这个

<meta http-equiv="X-UA-Compatible" content="IE=7" />

注意:已知会导致某些滚动条出现问题。

于 2012-06-15T00:04:08.440 回答