X-Git-Url: http://git.cyclocoop.org/clavettes/images/siteon3.jpg?a=blobdiff_plain;f=resources%2Fsrc%2Fmediawiki.action%2Fmediawiki.action.view.redirect.js;h=39a122d98103cc81889ecb131e8659c0e6e0cc15;hb=c0fb8a883633f110a8083a164672e8334714d450;hp=e66d8f6962078b7afc9c60d9d2c5532c1d2bfbd0;hpb=77e1b851dd3611cf6ce8f8771f47717907513c45;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..39a122d981 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 - 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; + // Note that this will update the hash in a modern browser, retaining back behaviour + history.replaceState( /* data= */ history.state, /* title= */ document.title, /* url= */ canonical ); + 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 ) {