放到带scrollbar的div里就可以了吧

解决方案 »

  1.   

    奇怪的问题
    如果onload的不行,再增加其他的事件如onresize
      

  2.   

    onload="javascript:if(this.width>screen.width-700)this.width=screen.width-700"onresize="javascript:if(this.width>screen.width-700)this.width=screen.width-700"
    就是在onload后面再写
      

  3.   

    因为图片比较多,用document.images[x].width 也很难知道是哪个
     rayFairy 的 onresize 我试过,也没用。不信请看:http://john6688.yp168.com
      

  4.   

    在放置图片的table 里加上style="table-layout:fixed;word-break:break-all;",table的宽高要有数值哦。这样的话,就不会担心它撑爆页面了,如果过长过高,table就会把它截掉。
      

  5.   

    用 table 中加css的办法,虽然可以不撑破页面,但这样就不能看到全部缩小后的图片。
    不是最佳的解决办法。
      

  6.   

    图片宽度做为300,高度按比例缩放。但把高度限制在500以下。用它来解决问题还是很方便的。function DrawImage(ImgD){ 
    var image=new Image(); 
    image.src=ImgD.src;
    ImgD.width=300; 
    ImgD.height=300*(image.height/image.width); 
    if(ImgD.height>=500){ 
    ImgD.height=500;
    }
    ImgD.alt=ImgD.width+"x"+ImgD.height; 
    }
    用法:<img  src="images/pic/aa.gif"  border="0" onload="javascript:DrawImage(this);">
      

  7.   

    <script language="JavaScript">
    <!--
    var flag=false;
    function DrawImage(ImgD){
       var image=new Image();
       var iwidth = 150;  //设置宽
       var iheight = 120;  //设置高
       image.src=ImgD.src;
       if(image.width>0 && image.height>0){
        flag=true;
        if(image.width/image.height>= iwidth/iheight){
         if(image.width>iwidth){  
         ImgD.width=iwidth;
         ImgD.height=(image.height*iwidth)/image.width;
         }else{
         ImgD.width=image.width;  
         ImgD.height=image.height;
         }
         ImgD.alt=image.width+"×"+image.height;
         }
        else{
         if(image.height>iheight){  
         ImgD.height=iheight;
         ImgD.width=(image.width*iheight)/image.height;     
         }else{
         ImgD.width=image.width;  
         ImgD.height=image.height;
         }
         ImgD.alt=image.width+"×"+image.height;
         }
        }

    //-->
    </script>
    <img src="。"  border="0" onload="javascript:DrawImage(this);">
    试试这个,还可以
      

  8.   

    <style>
    img {width:expression((this.width>screen.width-700) ? screen.width-700 : this.width)}
    </style>
      

  9.   

    使用以下方法:保证原图片长高比例,且不超过最大高度或宽度
    function initimg(parpic,maxwidth,maxheight)
    {
    var scale=maxwidth/maxheight;
    var realscale=parpic.width/parpic.height;
    if((parpic.width>maxwidth)||(parpic.height>maxheight))
    {
    if(realscale>scale)
    {
    parpic.width=maxwidth;
    }
    else
    {
    parpic.height=maxheight;
    }
    }
    }
    调用方法:
    图片中加onload事件如下:
    <img name="carpic" onload="initimg(this,165,176)" src="图片地址">
    其中165,176,则为强制最大宽度及高度.注意:该方法有时会对.gif格式图片处理失败!