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

    function getClientHeight()
    {
        //可见高
        var clientHeight=document.body.clientHeight;//其它浏览器默认值
        if(navigator.userAgent.indexOf("MSIE 6.0")!=-1)
        {
            clientHeight=document.body.clientHeight;
        }
        else if(navigator.userAgent.indexOf("MSIE")!=-1)
        {
            //IE7 IE8
            clientHeight=document.documentElement.offsetHeight
        }
    
        if(navigator.userAgent.indexOf("Chrome")!=-1)
        {
            clientHeight=document.body.scrollHeight;
        }
    
        if(navigator.userAgent.indexOf("Firefox")!=-1)
        {
            clientHeight=document.documentElement.scrollHeight;
        }
        return clientHeight;
    }
    
    //获得网页内容高度
    function getContentHeight()
    {
        //可见高
        var ContentHeight=document.body.scrollHeight;//其它浏览器默认值
    
        if(navigator.userAgent.indexOf("Chrome")!=-1)
        {
            ContentHeight= document.body.clientHeight;
        }
    
        if(navigator.userAgent.indexOf("Firefox")!=-1)
        {
            ContentHeight=document.body.offsetHeight;
        }
        return ContentHeight;
    }
  • 相关阅读:
    目录 —— C语言数据结构与算法分析
    目录 —— STM32裸机
    目录 —— FreeRTOS
    常用存储器介绍
    DMA(Data Memory Access)直接存储器访问
    命令
    文件数据流向
    野指针产生的原因
    内存四区
    SVG 是什么?
  • 原文地址:https://www.cnblogs.com/Shane-Chow/p/4384100.html
Copyright © 2011-2022 走看看