Anonymous
Anonymous

Reputation: 4632

Mouseout event does not trigger in IE 8

I have a trailing object following after the mouse. When the mouse gets out of the window, I want to hide it. This works ok in other browsers, but does not even trigger the event in IE8 >.<

If only I could trigger it, then guess it would work all right.

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

Please help to find where I made a mistake that it does not trigger...

Upvotes: 0

Views: 1146

Answers (2)

rlemon
rlemon

Reputation: 17666

window.attachEvent("mouseout", mouseport);

should be

document.attachEvent("onmouseout", mouseport);

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

Upvotes: 1

ppsreejith
ppsreejith

Reputation: 3438

Try adding this

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

note: it is known to cause problems with certain sscroll bars.

Upvotes: 0

Related Questions