It seems that IE8 lies about supporting "onhashchange" with the standard
feature test when in compatibility mode. So, sadly, we must add in an
explicit browser check if we want this to work.
Change-Id: Ib2c1b150acd0a0b5b16604e8623d6aa78017a9a0
// <a href="#.."> will naturally set the hash, handled by onhashchange.
// But other things that change the hash will also be catched (e.g. using
// the Back and Forward browser navigation).
- if ( 'onhashchange' in window ) {
+ // Note the special check for IE "compatibility" mode.
+ if ( 'onhashchange' in window &&
+ ( document.documentMode === undefined || document.documentMode >= 8 )
+ ) {
$(window).on( 'hashchange' , function () {
var hash = window.location.hash;
if ( hash.match( /^#mw-prefsection-[\w\-]+/ ) ) {