如何让chrome忘记页面滚动位置? [英] How to let the chrome forget the page scroll position?
本文介绍了如何让chrome忘记页面滚动位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如,我打开一个网页,向下滚动到某个位置,
For instance, I open a web page, and scroll down to some position,
,然后刷新Chrome浏览器,浏览器可以再次滚动上一个位置
then I refresh the chrome browser, the browser could scroll the previous position again
如何使用javascript或css让浏览器忘记滚动?
How can I use javascript or css to let the browser to forget the scroll?
c $ c> $(window).scrollTop(0),但不起作用
I have try $(window).scrollTop(0)
, but it doesn't work
推荐答案
p>一个简单的方法,我可以说是在页面加载运行此代码:
A simple way that I can say is to run this code on page load:
document.location = "#";
或
window.scrollTo(0);
它再次将浏览器视口设置到页面顶部。
It set the browser viewport to the top of the page, again.
这篇关于如何让chrome忘记页面滚动位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文