Chrome remembers scroll position

后端 未结 5 811
情话喂你
情话喂你 2020-12-05 04:52

I\'m running into a problem that\'s actually a \"feature\" on Chrome. As most of you might know, Chrome remembers a scroll position that it returns to, whenever you come bac

5条回答
  •  执笔经年
    2020-12-05 05:14

    Here is a clean way of getting this done.

    window.addEventListener('unload', function(e){
       document.body.style.display = 'none';
    });
    

    By simply setting the body display to 'none' you don't have to worry about a flash of the browser scrolling to the top of the page before it is unloaded and the scroll position will automatically be reset to 0.

提交回复
热议问题