<html> 
<head> 
<script type="text/javascript"> 
function changeSize() 
{
if(document.getElementById("compman").height="98"
{document.getElementById("compman").height="250" 
document.getElementById("compman").width="300" 
document.getElementById("bt").value="还原以前大小" 
}
else
{
document.getElementById("compman").height="98" 
document.getElementById("compman").width="107" 
document.getElementById("bt").value="改变图片大小"
}

</script> 
</head> <body> 
<img id="compman" src="My Pictures/Ecw.jpg" width="107" height="98" /> 
<br /> <br /> 
<input type="button" onClick="changeSize()" value="改变图片大小" id="bt"> 
</body> </html> 
方法是蠢了点,但可以实现你要的功能

解决方案 »

  1.   

    掉了个括号:
     
    if(document.getElementById("compman").height="98" )
      

  2.   

    <html>
    <head>
    <script type="text/javascript">
    function changeSize(img,obj){
        var niw = img.width;
        var nih = img.height;
        var iw=img.getAttribute("iw");
        var ih=img.getAttribute("ih");
        if(!iw){
            img.setAttribute("iw",niw);
            img.setAttribute("ih",nih);
        }
        img.width=(niw==300)?iw:300;
        img.height=(nih==250)?ih:250;
        obj.value=(obj.value=="改变图片大小")?"还原以前大小":"改变图片大小";
    }
    </script>
    </head><body>
    <img id="compman" src="My Pictures/Ecw.jpg" width="107" height="98" />
    <br /> <br />
    <input type="button" onClick="changeSize(document.getElementById('compman'),this)" value="改变图片大小" id="bt">
    </body></html>