在我使用脚本的网站上:
if (document.body.scrollTop < document.body.scrollHeight){
document.body.scrollTop += 50;
setTimeout(scroll, 100);
} else if (document.body.scrollTop >= document.body.scrollHeight) {
return false;
}
};
setTimeout(scroll, 100);
将页面滚动到最后,即使当前滚动位置的值与最大值相等,仍然不返回return。对没有框架的原生 JS 感兴趣。
.scrollTop
不能.scrollHeight
更像正确
您可以根据需要向 scrollTop 添加 50 像素,但是一旦到达页面底部,如果您将值设置为大于 ,它的值将不会改变
scrollHeight - clientHeight
。