width = img.width * (size[i-1] / 100);
height = img.height * (size[i-1] / 100);
确实有问题,你的图片最大化后,再点小,这时size[i-1]=size[5]=150
width = img.width * (size[i-1] / 100);等于把图片扩大了1.5倍。

解决方案 »

  1.   

    to:btut2004那我该怎么解决呢?忘能将的细些
      

  2.   


    <html>
    <title>画像</title>
    <body >
    画像<br>
    <img src="COWBOY01.JPG name="org1" border=1 >
    <hr><BR>
    <input type="button" name="prev" value="大" onClick="imgSize(true)">
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <input type="button" name="next" value="小" onClick="imgSize(false)">
    </body>
    </html>
    <script language="JavaScript">
    <!--
    var now = '100';
    var i=4;
    var img = document.images[0];
    var oldwidth=img.width;
    var oldheight=img.height;function imgSize(isContent)
    {
    var size = new Array('10','25','50','75','100','150','205');if(isContent)
    {
    if(now == '205')
    {
    alert("最大了");
    return;
    }
    else
    {
    i++;
    now=size[i]
    width = oldwidth * (now / 100);
    height = oldheight * (now / 100);
    }
    }
    else
    {
    if(now == '10')
    {
    alert("最小了");
    return;
    }
    else
    {
    i--;
    now=size[i];
    width = oldwidth * (now / 100);
    height = oldheight * (now / 100);
    }
    } document.images[0].width = width;
    document.images[0].height = height;}
    -->
    </script>
      

  3.   

    楼上的已经解决了.图像缩放:
    <input type="button" value="+"
    onmousedown="timer1=setInterval('mypic.width++;',30)" 
    onmouseup="clearInterval(timer1)">
    <input type="button" value="-"
    onmousedown="timer1=setInterval('mypic.width--;',30)" 
    onmouseup="clearInterval(timer1)">
    <br>
    <img src="http://community.csdn.net/images/CSDN_logo.GIF" id="mypic">
      

  4.   

    您定义的变量width;
        height;
    在按钮点击交替时并非变了原值,
      

  5.   

    改变图像大小的JS我写过一个,支持鼠标滚轮,请参见http://www.omeng.com/zphoto/