如何实现页面刷新后不定位到之前的滚动位置?

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

button.onclick = function () {
    if (history.scrollRestoration) {
          history.scrollRestoration = 'manual';
    }    
}

 

来源:

https://www.zhangxinxu.com/wordpress/2022/05/history-scrollrestoration/

posted @ 2023-02-09 16:45  小小强学习网  阅读(21)  评论(0编辑  收藏  举报