亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

js實現(xiàn)圖片等比縮放

オリジナル 2016-11-08 11:09:31 356
サマリー://圖片等比例縮放  <html> <head> <title>等比例縮放圖片</title> <script> function DrawImage(ImgD,iwidth,iheight){           //參數(shù)(圖片
//圖片等比例縮放 
<html>
<head>
<title>等比例縮放圖片</title>
<script>
function DrawImage(ImgD,iwidth,iheight){   
  
    //參數(shù)(圖片,允許的寬度,允許的高度)   
  
    var image=new Image();   
  
    image.src=ImgD.src;   
  
    if(image.width>0 && image.height>0){   
  
      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;   
  
          }   
  
      }else{   
  
          if(image.height>iheight){     
  
              ImgD.height=iheight;   
  
              ImgD.width=(image.width*iheight)/image.height;           
  
          }else{   
  
              ImgD.width=image.width;     
  
              ImgD.height=image.height;   
  
          }   
  
      }   
  
    }   
  
}  
  
</script> 
</head>
<body>
<img src="/images/logo.gif" alt="自動縮放后的效果" width="220" height="80" onload="javascript:DrawImage(this,100,100)" />
</body>
</html>


手記を発表する

人気のある見出し語