<img src="xxx.jpg" id=1>
<script>
alert(document.images(1).width)
alert(document.images("1").src)
if(document.images("1").width<300) document.images("1").width=400
</script>

解决方案 »

  1.   

    是这个吗?
    <div style="overflow:scroll; width:300; height:200"><img width="400" height="300" alt="this is a img"></div>
      

  2.   

    <body onload=imgfunction()>
    <img src="zz_hdb.gif" id=outimg>
    <script>
    function imgfunction(){
    if (outimg.width>300) outimg.width=300;
    if (outimg.height>200) outimg.height=200;
    }
    </script>
    </body>
      

  3.   

    不想要滚动条,去掉不就行了吗?
    overflow:hidden;
    <div style="overflow:hidden; width:300; height:200"><img alt="this is a img"></div>
      

  4.   

    这是我写的一个自动调整图片大小的程序﹐不过缺点是打开图片之后再调整大小﹐你可以根据你的要求调整纵横比和最大宽高。
    <% s_img=request("filename") %>
    <html>
    <head>
    <title>附件内容</title>
    <meta http-equiv="Content-Type" content="text/html; charset=big5">
    <script>
    function showpicture(as_img){
    window.moveTo(0,0)
    window.resizeTo(window.screen.width,window.screen.height)
    document.photo.src=as_img
    var img_x,img_y
    img_x = window.screen.width - 50
    img_y = document.photo.height / ( document.photo.width / (window.screen.width - 50))
    document.photo.width=img_x
    document.photo.height=img_y
    }
    </script>
    </head>
    <body bgcolor="#FFFFFF" text="#000000" onload="showpicture('<%=s_img%>')">
    <form name="form1" method="post" action="">
    <p align="center"><img name=photo></p>
    </form>
    </body>
    </html>