How to disable anchor “jump” when loading a page?

Does your fix not work? I’m not sure if I understand the question correctly – do you have a demo page? You could try:

if (location.hash) {
  setTimeout(function() {

    window.scrollTo(0, 0);
  }, 1);
}

Edit: tested and works in Firefox, IE & Chrome on Windows.
Edit 2: move setTimeout() inside if block, props @vsync.

Leave a Comment