本文主要介绍了js简单实现滑动加载数据的方法,涉及javascript事件响应及页面元素属性动态操作相关技巧,需要的朋友可以参考下,希望能帮助到大家。
//滑动 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()) { //dosomething } }
相关推荐:
javascript - js如何在滑动加载的时候限定滑动的加载次数
Javascript vue.js表格分页,ajax异步加载数据
Bootstrap treeview实现动态加载数据及快捷搜索功能的实现
以上就是JS简单实现滑动加载数据实例分享的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号