var dd=document.getElementById("Img1");
dd.style.width='100px';
dd.style.height='100px';试试吧

解决方案 »

  1.   

    document.getElementById("Img1").style.width=100; 
    document.getElementById("Img1").style.height=100; 
      

  2.   


    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>未命名頁面</title>
        
    <script language="javascript" type="text/javascript">
    // <!CDATA[function Button1_onclick() {
    document.getElementById('img1').style.height=30;
    document.getElementById('img1').style.width=30;
    }// ]]>
    </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <img id="img1" src="Image/P2P_1.jpg"/>
            <input id="Button1" type="button" value="button" onclick="return Button1_onclick()" />
        
        </form>
    </body>
    </html>
      

  3.   

    document.getElementById("Img1").style.width=100;  
    document.getElementById("Img1").style.height=100;  
      

  4.   

    没问题啊,不过最好是设置style中的width和height<html>
    <head>
    <title></title>
    </head>
    <body>
    <input type='button' onclick='setSize()' value='重新设置'/><br/>
    <script>
    function setSize()
    {
      var im=document.getElementById("img1");
      im.width=100;
      im.height=100;
    }
    </script>
    <img id='img1' src='xx1.gif'/>
    </body>
    </html>
      

  5.   

    解决了,因为不要在STYLE中设置WIDTH&HEIGHT