javascript 在页面加载时设置滚动位置
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13897603/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 20:06:01 来源:igfitidea点击:
Set scroll position on page load
提问by ThomasReggi
I am looking to set the page scroll on page load. I can set it by div scroll top or just pixel height.
我希望在页面加载时设置页面滚动。我可以通过 div scroll top 或仅像素高度来设置它。
回答by Wing Lian
$(document).ready(function() {
$(document).scrollTop(100);
});
回答by Jad Joubran
Use window.load instead because the load of some images might affect your scrolling position
使用 window.load 代替,因为某些图像的加载可能会影响您的滚动位置
$(window).load(function() {
$(document).scrollTop(100);
});