js滚动加载到底部
发布日期:2021-08-26 16:37:47 浏览次数:12 分类:技术文章

本文共 937 字,大约阅读时间需要 3 分钟。

<script>

//获取滚动条当前的位置
function getScrollTop() {
var scrollTop = 0;
if (document.documentElement && document.documentElement.scrollTop) {
scrollTop = document.documentElement.scrollTop;
}
else if (document.body) {
scrollTop = document.body.scrollTop;
}
return scrollTop;
};
//获取当前可是范围的高度
function getClientHeight() {
var clientHeight = 0;
if (document.body.clientHeight && document.documentElement.clientHeight) {
clientHeight = Math.min(document.body.clientHeight, document.documentElement.clientHeight);
}
else {
clientHeight = Math.max(document.body.clientHeight, document.documentElement.clientHeight);
}
return clientHeight;
};
//获取文档完整的高度
function getScrollHeight() {
return Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
};

window.onscroll = function () {

if (getScrollTop() + getClientHeight() == getScrollHeight()) {
alert("到达底部");
}
}
</script>

转载于:https://www.cnblogs.com/togetherzy/p/5416687.html

转载地址:https://blog.csdn.net/weixin_33890526/article/details/93882212 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:关于mac远程链接window服务器以及实现共享文件
下一篇:nginx 的windows 基本配置

发表评论

最新留言

能坚持,总会有不一样的收获!
[***.219.124.196]2025年02月12日 05时38分50秒