js 监听页面滚动到底部,监听可视区域滚动到底部

全局页面body上的底部监听:
window.onscroll = function(){
var scrollTop = document.documentElement.scrollTop||document.body.scrollTop;
var windowHeight = document.documentElement.clientHeight || document.body.clientHeight;
var scrollHeight = document.documentElement.scrollHeight||document.body.scrollHeight;
if(scrollTop+windowHeight>=scrollHeight){ //考虑到滚动的位置一般可能会大于一点可滚动的高度,所以这里不能用等于
console.log("距顶部"+scrollTop+"可视区高度"+w

js 监听页面滚动到底部,监听可视区域滚动到底部最先出现在Python成神之路

版权声明:
作者:Zad
链接:https://www.techfm.club/p/25858.html
来源:TechFM
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
< <上一篇
下一篇>>