MediaWiki:Common.js: Difference between revisions

mNo edit summary
mNo edit summary
Line 116: Line 116:
mw.hook('wikipage.content').add(function () {
mw.hook('wikipage.content').add(function () {


  const hash = window.location.hash;
   if (!location.hash) return;   // IMPORTANT: do nothing without anchor
   if (!hash) return;


   const id = hash.replace('#','');
   const id = location.hash.slice(1);


   setTimeout(function(){
   setTimeout(function(){
Line 141: Line 140:
     panel.scrollIntoView({block:'start'});
     panel.scrollIntoView({block:'start'});


    /* IMPORTANT: remove hash so script does not re-trigger */
   },150);
    history.replaceState(null, null, window.location.pathname);
 
   },200);


});
});