当前位置:网站首页>JS -- prevent automatic recovery of page position

JS -- prevent automatic recovery of page position

2022-06-11 23:59:00 HarryHY

Prevent automatic recovery of page position

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

View the current page scrolling recovery behavior

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

Document links

原网站

版权声明
本文为[HarryHY]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/162/202206112355302297.html