javascriptcssgoogle-chromescroll

How to let the chrome forget the page scroll position?


For instance, I open a web page, and scroll down to some position,

then I refresh the chrome browser, the browser could scroll the previous position again

How can I use javascript or css to let the browser to forget the scroll?

I have try $(window).scrollTop(0), but it doesn't work


Solution

  • A simple way that I can say is to run this code on page load:

    document.location = "#";
    

    OR

    window.scrollTo(0);
    

    It set the browser viewport to the top of the page, again.