I've run into a small problem while detecting when user leaves the window in IE8. I am aware that addEventListener method is supported only in IE9+ versions so I came up with this solution:
function popUp() {
console.log("i'm leaving")
}
if (window.addEventListener) {
window.addEventListener("mouseout", popUp);
} else {
window.attachEvent("mouseout", popUp);
}
It works properly in all major browsers, but still fails in IE8. I hoped that using jQuery will solve the problem:
$(window).mouseout(function(){
popUp()
})
but, due to this information, neither mouseover nor mouseout events work on the window in IE8.
So the question is, how can I make it work in this quite obsolete, but unfortunately still popular browser? Any help would be really appreciated