It seems that IE (testing IE8) doesn't bubble events to the window
.
Here's an example ( http://jsfiddle.net/SZXrn/8/ ):
if (window.attachEvent) // IE
{
window.attachEvent('onclick', function () {
alert("Yay window obj was clicked! IE");
});
document.attachEvent('onclick', function () {
alert("Yay document obj was clicked! IE");
});
}
else if (window.addEventListener) // Other
{
window.addEventListener('click', function () {
alert("Yay window obj was clicked! Non-IE");
});
document.addEventListener('click', function () {
alert("Yay document obj was clicked! Non-IE");
});
}
So, the solution is to bind to the document
instead of window
.