- // 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();
+ }