zoukankan      html  css  js  c++  java
  • 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) {
                var clientHeight = (document.body.clientHeight < document.documentElement.clientHeight) ? document.body.clientHeight : document.documentElement.clientHeight;
            }
            else {
                var clientHeight = (document.body.clientHeight > document.documentElement.clientHeight) ? 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('页面底部');
        }
    }
  • 相关阅读:
    【制作镜像Win*】系统配置
    【制作镜像Win*】系统安装
    【制作镜像Win*】文件准备
    【制作镜像Win*】环境准备
    【制作镜像Win*】环境准备(设置yum源)
    Portal
    bc
    2-模拟登录淘宝
    10-天猫订单数据分析
    2-Scala进阶
  • 原文地址:https://www.cnblogs.com/yxfboke/p/11535117.html
Copyright © 2011-2022 走看看