document.getElementById('div1').style.width=100
document.getElementById('div1').style.height=100

解决方案 »

  1.   

    层ID为 XXXXXX.style.Width='100'
    XXX.style.Height='100'
      

  2.   

    document.all("xxx").style.width="20";
    document.all("xxx").style.height="120";
      

  3.   

    1、width和height都是小写的
    2、可以赋值数字或字符串,比如=12和="12"和="12px"相同,还可以="80%"
      

  4.   

    document.getElementById('div1').offsetWidth
    document.getElementById('div1').offsetHeight
      

  5.   

    document.all.item("my_layer_name").width = 100;
    document.all.item("my_layer_name").height = 100;
      

  6.   

    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    </head><body>
    <div id="Layer1"></div>
    <script language="JavaScript">
      if(Layer1.style.width==0 || Layer1.style.height==0)
      {
         Layer1.style.width=100;
         Layer1.style.height=100;
         alert(Layer1.style.width + "/" + Layer1.style.height);
      }
      else alert(Layer1.style.width + "/" + Layer1.style.height);
    </script>
    </body>
    </html>
      

  7.   

    <script>
    alert("div width is:"+document.all("层的名称").style.width);
    alert("div height is:"+document.all("层的名称").style.height);
    </script>