在IE下offsetHeight为127但在FF下为29,要兼容怎么办?
但是offsetWidth的值相同。

解决方案 »

  1.   

    IE下认为offsetHeight = clientHeight + 滚动条 + 边框。
    FF则认为 offsetHeight 是网页内容实际高度,可以小于 clientHeight。
    这两者的机制不同,
    方法一:建议你将两种情况分开,一种针对IE,一种针对FF.
    方法二:如果可以的话,可以调整你页面的架构,来同时适应这两种情况.
      

  2.   

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    <title> New Document </title>
    <meta name="Generator" content="EditPlus">
    <meta name="Author" content="">
    <meta name="Keywords" content="">
    <meta name="Description" content="">
    </head><body>
    <div id="a1"><br />dfsdfdfdsf<br /><br /><br /><br /><br /><br /><br />dfdsfdfdsfdsfds</div>
    <div id="a2"></div>
    <script>
    var xScroll, yScroll;
    if (window.innerHeight && window.scrollMaxY) {
    xScroll = document.getElementById("a1").scrollWidth;
    yScroll = document.getElementById("a1").innerHeight + document.getElementById("a1").scrollMaxY;
    } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
    xScroll = document.getElementById("a1").scrollWidth;
    yScroll = document.getElementById("a1").scrollHeight;
    } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
    xScroll = document.getElementById("a1").offsetWidth;
    yScroll = document.getElementById("a1").offsetHeight;
    }
    document.getElementById("a2").innerHTML="x:"+xScroll+",y:"+yScroll;
    </script>
    </body>
    </html>
      

  3.   

    if (window.innerHeight) alert(obj.parentNode.innerHeight); 对话框能弹出但显示undefine
      

  4.   

    http://dev.csdn.net/develop/article/54/54510.shtm