zoukankan      html  css  js  c++  java
  • js获取滚动条的位置

    页面具有 DTD,或者说指定了 DOCTYPE 时,使用 document.documentElement。

    页面不具有 DTD,或者说没有指定了 DOCTYPE,时,使用 document.body。

    在 IE 和 Firefox 中均是如此。

    这个是兼容的方法:
    function ScollPostion() {//滚动条位置
    var t, l, w, h;
    if (document.documentElement && document.documentElement.scrollTop) {
    t = document.documentElement.scrollTop;
    l = document.documentElement.scrollLeft;
    w = document.documentElement.scrollWidth;
    h = document.documentElement.scrollHeight;
    } else if (document.body) {
    t = document.body.scrollTop;
    l = document.body.scrollLeft;
    w = document.body.scrollWidth;
    h = document.body.scrollHeight;
    }
    return { top: t, left: l, w, height: h };
    }
  • 相关阅读:
    微博Feed流
    朋友圈
    Go命令行—compile
    Practical Go: Real world advice for writing maintainable Go programs
    Nginx Cache-Control
    Redis 主从复制
    JAVA
    Tomcat
    Tomcat
    CentOS 7
  • 原文地址:https://www.cnblogs.com/stevenjson/p/3443789.html
Copyright © 2011-2022 走看看