X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=resources%2Fsrc%2Fmediawiki.action%2Fmediawiki.action.view.redirect.js;h=29a5a79f9bdd0595420aae0e15eb1d89b36b9ec4;hb=121454a6058a0a4dcdb03abf0b53be73c5ca96ad;hp=e66d8f6962078b7afc9c60d9d2c5532c1d2bfbd0;hpb=96366c1cf1966ca07e8f0b4361bbca28bfaf43a0;p=lhc%2Fweb%2Fwiklou.git diff --git a/resources/src/mediawiki.action/mediawiki.action.view.redirect.js b/resources/src/mediawiki.action/mediawiki.action.view.redirect.js index e66d8f6962..29a5a79f9b 100644 --- a/resources/src/mediawiki.action/mediawiki.action.view.redirect.js +++ b/resources/src/mediawiki.action/mediawiki.action.view.redirect.js @@ -9,7 +9,7 @@ var profile = $.client.profile(), canonical = mw.config.get( 'wgInternalRedirectTargetUrl' ), fragment = null, - shouldChangeFragment, index; + node, shouldChangeFragment, index; index = canonical.indexOf( '#' ); if ( index !== -1 ) { @@ -27,12 +27,15 @@ canonical += location.hash; } - // This will also cause the browser to scroll to given fragment + // Note that this will update the hash in a modern browser, retaining back behaviour history.replaceState( /*data=*/ history.state, /*title=*/ document.title, /*url=*/ canonical ); - - // …except for IE 10 and 11. Prod it with a location.hash change. - if ( shouldChangeFragment && profile.name === 'msie' && profile.versionNumber >= 10 ) { - location.hash = fragment; + if ( shouldChangeFragment ) { + // Specification for history.replaceState() doesn't require browser to scroll, + // so scroll to be sure (see also T110501). Support for IE9 and IE10. + node = document.getElementById( fragment.slice( 1 ) ); + if ( node ) { + node.scrollIntoView(); + } } } else if ( shouldChangeFragment ) {