页面刷新后禁用浏览器的自动滚动? [英] Disable brower's auto scroll after a page refresh?
本文介绍了页面刷新后禁用浏览器的自动滚动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法禁用某些现代浏览器(Chrome 和 Safari)在页面刷新时记住您的滚动位置的行为?
Is there a way to disable the behavior where some modern browsers (Chrome and Safari) remember your scroll position on a page refresh?
推荐答案
对于支持 history.scrollRestoration 的浏览器,可以关闭自动滚动行为:
For browsers that support history.scrollRestoration, the auto scroll behavior can be turned off:
if ('scrollRestoration' in history) {
history.scrollRestoration = 'manual';
}
来源:https://developers.google.com/web/updates/2015/09/history-api-scroll-restoration
这篇关于页面刷新后禁用浏览器的自动滚动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文