繁体   English   中英

Mouseout 事件不会在 IE 8 中触发

[英]Mouseout event does not trigger in IE 8

我在鼠标之后有一个尾随对象。 当鼠标离开窗口时,我想隐藏它。 这在其他浏览器中工作正常,但在 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);
            }
        }

请大家帮忙找出是哪里出错了,不触发...

window.attachEvent("mouseout", mouseport);

应该

document.attachEvent("onmouseout", mouseport);

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

尝试添加这个

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM