当前位置:网站首页>JS——防止自动恢复页面位置

JS——防止自动恢复页面位置

2022-06-11 23:55:00 HarryHY

防止自动恢复页面位置

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

查看当前页面滚动恢复行为

const scrollRestoration = history.scrollRestoration
if (scrollRestoration === 'manual') {
    
  console.log('The location on the page is not restored, user will need to scroll manually.');
}

文档链接

原网站

版权声明
本文为[HarryHY]所创,转载请带上原文链接,感谢
https://blog.csdn.net/HarryHY/article/details/125204860