监听是否到达页面滑动的可视区域最底部

 1 function getScrollTop(){
 2                 var scrollTop = 0, bodyScrollTop = 0, documentScrollTop = 0;
 3                 if(document.body){
 4                 bodyScrollTop = document.body.scrollTop;
 5               }
 6               if(document.documentElement){
 7                 documentScrollTop = document.documentElement.scrollTop;
 8               }
 9               scrollTop = (bodyScrollTop - documentScrollTop > 0) ? bodyScrollTop : documentScrollTop;
10               return scrollTop;
11             }
12             //文档的总高度
13             function getScrollHeight(){
14                 var scrollHeight = 0, bodyScrollHeight = 0, documentScrollHeight = 0;
15                 if(document.body){
16                 bodyScrollHeight = document.body.scrollHeight;
17               }
18               if(document.documentElement){
19                 documentScrollHeight = document.documentElement.scrollHeight;
20               }
21               scrollHeight = (bodyScrollHeight - documentScrollHeight > 0) ? bodyScrollHeight : documentScrollHeight;
22               return scrollHeight;
23             }
24             //浏览器视口的高度
25             function getWindowHeight(){
26                 var windowHeight = 0;
27               if(document.compatMode == "CSS1Compat"){
28                 windowHeight = document.documentElement.clientHeight;
29               }else{
30                 windowHeight = document.body.clientHeight;
31               }
32               return windowHeight;
33             }
34             //监听滚动条的事件内容
35             window.onscroll = function(){
36               if(getScrollTop() + getWindowHeight() == getScrollHeight()){
37                     console.log("getScrollTop:"+getScrollTop()+"**getWindowHeight:"+getWindowHeight()+"**getScrollHeight:"+getScrollHeight())
38               }
39             };

 原链接地址:https://blog.csdn.net/qq_29301417/article/details/78684495

原文地址:https://www.cnblogs.com/Salicejy/p/10839536.html