I want to check if the browser supports hashchange
event and, if not, fake it with setInterval
.
I have tried
if ('onhashchange' in window) {
window.onhashchange = hashChange;
} else {
/* setInterval graceful degradation */
}
But the problem is that, in IE8 in IE7 Compat mode, 'onhashchange' in window
returns true
because window.onhashchange
is null
(jsfiddle)
Why does it happen? If I use 'onclick2' in window
, it returns false
!
I have read Detecting support for a given JavaScript event?, but I would prefer to use something simpler if possible.
It seems
'onhashchange' in window
wastrue
because I was using IE8 in IE7 mode instead of real IE7But I have just tried it with IETester and
'onhashchange' in window
givesfalse
.Now, I wonder why does IE 8 have IE7 mode if it can't emulate IE7 very well