Prevent Refresh 'Jump' with Javascript

后端 未结 5 830
滥情空心
滥情空心 2021-02-05 17:20

I\'ve noticed that if you are on a page and you have scrolled down a good bit, if you refresh the page, most browsers will jump you back down to your position. Is there any way

5条回答
  •  青春惊慌失措
    2021-02-05 17:49

    Works for me:

    // Scroll top bro
    window.onload = function() {
     setTimeout (function () {
      scrollTo(0,0);
     }, 0);
    }
    

提交回复
热议问题