guo2001china

<script type="text/javascript">
<!--
/*
功能:图片等比例缩放
目标:ImgTag
图片宽度:FitWidth
图片高度:FitHeight
*/
//var FitWidth = 120;
//var FitHeight = 120;
function ResizePic(ImgTag,FitWidth,FitHeight)
{
 var image = new Image();
 image.src = ImgTag.src;
 if(image.width>0 && image.height>0){
  if(image.width/image.height >= FitWidth/FitHeight){
   if(image.width > FitWidth){
    ImgTag.width = FitWidth;
    ImgTag.height = (image.height*FitWidth)/image.width;
   }
   else{
    ImgTag.width = image.width;
    ImgTag.height = image.height;
   }
  }
  else{
   if(image.height > FitHeight){
    ImgTag.height = FitHeight;
    ImgTag.width = (image.width*FitHeight)/image.height;
   }
   else{
    ImgTag.width = image.width;
    ImgTag.height = image.height;
   }
  }
 }
}
//-->
</script>

应用:

<img src=\'UpFile/1.jpg\' onload=\'ResizePic(this,550,500) \'/>

分类:

技术点:

相关文章:

  • 2021-12-31
  • 2021-12-31
  • 2021-12-31
  • 2021-12-31
  • 2021-12-31
  • 2021-12-31
  • 2021-12-31
  • 2021-12-31
猜你喜欢
  • 2021-12-31
  • 2021-12-31
  • 2021-12-31
  • 2021-09-28
  • 2021-12-31
  • 2021-12-31
  • 2021-12-31
相关资源
相似解决方案