弄个隐藏域,保存上次修改的width和height

解决方案 »

  1.   

    可以用
    var img = new Image();
    img.src="xxx";
    这样的方式预加载也可以在生成旁边图片名称的时候 得出其对应图片的width,height属性 
    点击更改的时候将右边的width,height也改了
      

  2.   

    在加载另一幅图片前把width、height复位一下不行吗?
      

  3.   

    可以先将原来的<img>去掉,再新建一个img标签,设置src后加进去。
      

  4.   

    保存之前的尺寸肯定不行,预加载这里不太好改可能还得动结构。
    通过URL不知道能不能直接读出原始文件的尺寸
      

  5.   


    <SCRIPT LANGUAGE="JavaScript">
    function fun(obj)
    {
    var img = new Image();
    img.src=obj.src;
    obj.width=img.width;
    obj.height=img.height;
    }
    </SCRIPT>
    <img src="" onload="fun(this)">这样呢
      

  6.   

    使用id 搭配innerHtml 每次重写<img> 标签。
      

  7.   

    <html>
    <head>
    <script>
    var imgs=[
    "http://avatar.profile.csdn.net/2/E/9/2_Teng_s2000.jpg",
    "http://zi.csdn.net/475×60.gif",
    "http://www.csdn.net/Images/logo_csdn.gif"
    ]
    var _picIndex = 0;
    window.onload=function(){
      $("im").src=imgs[_picIndex];
    }function nextPic()
    {
       _picIndex++;
      if(_picIndex>imgs.length-1)
      {
         _picIndex = 0;
      }
      $("im").style["width"]=null;
      $("im").style["height"]=null;
      $("im").src=imgs[_picIndex];
    }function zoonOut()
    {
      var w = $("im").offsetWidth*1.2;
      var h = $("im").offsetWidth*1.2;
      $("im").style.width=w;
      $("im").style.hight=h;
    }
    function $(id)
    {
      return document.getElementById(id);
    }
    </script>
    <body>
    <img id="im" style="border:dashed 1px #ccc">
    <br>
    <input type="button" value="+" onclick="zoonOut()">
    <input type="button" value="Next" onclick="nextPic()">
    </div>
    </body>
    </html>