zoukankan      html  css  js  c++  java
  • 滚动监听

    function getScrollTop(){
      var scrollTop = 0, bodyScrollTop = 0, documentScrollTop = 0;
      if(document.body){
        bodyScrollTop = document.body.scrollTop;
      }
      if(document.documentElement){
        documentScrollTop = document.documentElement.scrollTop;
      }
      scrollTop = (bodyScrollTop - documentScrollTop > 0) ? bodyScrollTop : documentScrollTop;
      return scrollTop;
    }
    //文档的总高度
    function getScrollHeight(){
      var scrollHeight = 0, bodyScrollHeight = 0, documentScrollHeight = 0;
      if(document.body){
        bodyScrollHeight = document.body.scrollHeight;
      }
      if(document.documentElement){
        documentScrollHeight = document.documentElement.scrollHeight;
      }
      scrollHeight = (bodyScrollHeight - documentScrollHeight > 0) ? bodyScrollHeight : documentScrollHeight;
      return scrollHeight;
    }
    //浏览器视口的高度
    function getWindowHeight(){
      var windowHeight = 0;
      if(document.compatMode == "CSS1Compat"){
        windowHeight = document.documentElement.clientHeight;
      }else{
        windowHeight = document.body.clientHeight;
      }
      return windowHeight;
    }
    window.onscroll = function(){
      if(getScrollTop() + getWindowHeight() == getScrollHeight()){
       document.getElementsByClassName('footer')[0].style.display='flex';
    }else{
    document.getElementsByClassName('footer')[0].style.display='none';
      }
    };
    document.getElementsByClassName('footer')[0].onclick=function(){
    document.body.scrollTop=0;
    }

  • 相关阅读:
    sharepoint 2007 升级到 sharepoint 2013
    sharepoint 2010中启用RBS及所遇问题
    sharepoint 读取文件夹中所有的数据
    脚本设置ip&自动获取ip
    window 2008 r2 每隔一小时都要重启一次解决办法
    sharepoint 弹出框
    sharepoint powershell 根据报错的GUID查询错误
    java中switch选择结构
    mysql查看表字段相关信息
    mac系统 -postman发送http请求
  • 原文地址:https://www.cnblogs.com/QxkWeb/p/7488100.html
Copyright © 2011-2022 走看看