Disable brower's auto scroll after a page refresh? Disable brower's auto scroll after a page refresh? google-chrome google-chrome

Disable brower's auto scroll after a page refresh?


For browsers that support history.scrollRestoration, the auto scroll behavior can be turned off:

if ('scrollRestoration' in history) {  history.scrollRestoration = 'manual';}

source: https://developers.google.com/web/updates/2015/09/history-api-scroll-restoration


Have you tried firing this after document is ready?

$(document).ready(function(){    window.scrollTo(0, 0);});

if that does not work...

$(document).ready(function(){    setTimeout(function(){        window.scrollTo(0, 0);    }, 1);});

Which will push this to the bottom of the call stack


not just for chrome,but for all i think this will work well.

window.onload = function () {    window.scrollTo(0, 0);};

After update of your question:

I think its better if we use some cookies or session storage.