ame*_*_me 25 html javascript scroll google-chrome viewport
我遇到的问题实际上是Chrome上的"功能".正如大多数人可能知道的那样,只要您回到页面,Chrome就会记住它返回的滚动位置.我有点问题.
有没有办法在没有用户注意的情况下覆盖它?
米斯
试用失败:
小智 58
在Chrome 46+中,可以使用history.scrollRestoration关闭自动滚动行为:
if ('scrollRestoration' in history) {
history.scrollRestoration = 'manual';
}
Run Code Online (Sandbox Code Playgroud)
来源:https://developers.google.com/web/updates/2015/09/history-api-scroll-restoration
Ikr*_*rom 10
我检查过铬,效果很好.有时setTimeout会欺骗:)
<script type="text/javascript">
window.onload=function(){
setTimeout(function(){
scrollTo(0,-1);
},0);
}
</script>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
16586 次 |
| 最近记录: |