IE有效的,,非IE系列全部失效,但是用console.log(div2.offsetHeight)  有数据的

解决方案 »

  1.   

    http://www.itdos.com/javascript/86.html
      

  2.   

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
     <head>
      <title> New Document </title>
      <meta name="Generator" content="EditPlus">
      <meta name="Author" content="">
      <meta name="Keywords" content="">
      <meta name="Description" content="">
      <script>
    function addHeight(){
    var div1 = document.getElementById("div1");
    var div2 = document.getElementById("div2");
    div2.style.height = div2.style.height.slice(0,-2)-'0' + 50 + "px";
    }
      </script>
     </head> <body>
      <button onclick="addHeight()">变高</button>
      <div style="position:absolute;left:0px;width:200px;height:200px;background:red" id="div1"></div>
      <div style="position:absolute;left:300px;width:200px;height:200px;background:red" id="div2"></div>
      
     </body>
    </html>
    你这样写吧。都可以用,在ie中,可以不带单位,在firefox中带单位的。