zoukankan      html  css  js  c++  java
  • js滚动条

    /*滚动条在Y轴上的滚动距离*/
    function ScrollTop()
    {
    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 ScrollHeight()
    {
    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 WindowHeight()
    {
    var windowHeight = 0;
    if (document.compatMode == "CSS1Compat")
    {
    windowHeight = document.documentElement.clientHeight;
    } else
    {
    windowHeight = document.body.clientHeight;
    }
    return windowHeight;
    }
    window.onscroll = function()
    {
    if (ScrollTop() + WindowHeight() + 5 >= ScrollHeight())
    {
    More();
    }
    };

  • 相关阅读:
    iOS 进阶 第一天(0323)
    iOS 基础 第五天(0811)
    iOS 基础 第四天(0809)
    iOS 基础 第三天(0808)
    iOS 基础 第三天(0807)
    iOS 基础 第二天(0805)
    iOS 基础 第一天(0804)
    Mac 启用http-dav功能(WebDAV服务器)
    【转】phpmyadmin万能密码漏洞
    关于python文件操作 (转载)
  • 原文地址:https://www.cnblogs.com/ghelement/p/4511328.html
Copyright © 2011-2022 走看看