zoukankan      html  css  js  c++  java
  • JS 获取网页内容高度 和 网页可视高度 支持IE 6789 Firefox Chrome

    1 function getClientHeight()
     2 {
     3     //可见高
     4     var clientHeight=document.body.clientHeight;//其它浏览器默认值
     5     if(navigator.userAgent.indexOf("MSIE 6.0")!=-1)
     6     {
     7         clientHeight=document.body.clientHeight;
     8     }
     9     else if(navigator.userAgent.indexOf("MSIE")!=-1)
    10     {
    11         //IE7 IE8
    12         clientHeight=document.documentElement.offsetHeight
    13     }
    14 
    15     if(navigator.userAgent.indexOf("Chrome")!=-1)
    16     {
    17         clientHeight=document.body.scrollHeight;
    18     }
    19 
    20     if(navigator.userAgent.indexOf("Firefox")!=-1)
    21     {
    22         clientHeight=document.documentElement.scrollHeight;
    23     }
    24     return clientHeight;
    25 }
    26 
    27 //获得网页内容高度
    28 function getContentHeight()
    29 {
    30     //可见高
    31     var ContentHeight=document.body.scrollHeight;//其它浏览器默认值
    32 
    33     if(navigator.userAgent.indexOf("Chrome")!=-1)
    34     {
    35         ContentHeight= document.body.clientHeight;
    36     }
    37 
    38     if(navigator.userAgent.indexOf("Firefox")!=-1)
    39     {
    40         ContentHeight=document.body.offsetHeight;
    41     }
    42     return ContentHeight;
    43 }

  • 相关阅读:
    Codeforces 1255B Fridge Lockers
    Codeforces 1255A Changing Volume
    Codeforces 1255A Changing Volume
    leetcode 112. 路径总和
    leetcode 129. 求根到叶子节点数字之和
    leetcode 404. 左叶子之和
    leetcode 104. 二叉树的最大深度
    leetcode 235. 二叉搜索树的最近公共祖先
    450. Delete Node in a BST
    树的c++实现--建立一棵树
  • 原文地址:https://www.cnblogs.com/aim-at-is-the-tao-in/p/3398584.html
Copyright © 2011-2022 走看看