如题,用
document.getElementById("image1").width=100;
document.getElementById("image1").height=100;
好像都不行,
郁闷啊!

解决方案 »

  1.   

    document.getElementById("image1").style.width=100px; 
      

  2.   

    没有重绘的话,应该是不行的。
    建议用ajax实现吧
      

  3.   

    楼主大概是把id弄错了
    的确是这样写的
    我用这个试过了
    var flag=false;
    function IMG1_onclick()

      if(flag)
      {
        document.getElementById("IMG1").width=300; 
        document.getElementById("IMG1").height=100; 
        flag=false;
        return;
      }
      document.getElementById("IMG1").width=100; 
      document.getElementById("IMG1").height=300; 
      flag=true;
    }
      

  4.   

    使用CSS来定width height比较有效
    $("#img1").css({width:$w,height:$h, marginLeft:(wContainer-$w)*.5,marginTop:(hContainer-$h)*.5})
    我用的是jQuery库  快截开发 也很容易记容易理解`~
      

  5.   

    document.getElementById("image1").style.width="100px";
    document.getElementById("image1").style.height="100px";
    补充下 ` jQuery兼容性很好`
      

  6.   

    给个另外的写法,IE和FF中都兼容document.getElement("image1").setAttribute("width","100px");document.getElement("image2").setAttribute("height","100px");
      

  7.   

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

  8.   

    多谢兄弟们,解决了,是因为不能在STYLE中写入HEIGHT和WIDTH
    结贴,给分!