发新话题
打印

ASP中如何控制图片大小,(如何实现等比缩放)?

ASP中如何控制图片大小,(如何实现等比缩放)?

ASP中如何控制图片大小,(如何实现等比缩放)?  
谢谢大家!!!

TOP

放入head里面  
<script  language="JavaScript">  
<!--  
var  flag=false;  
function  DrawImage(ImgD){  
     var  image=new  Image();  
     image.src=ImgD.src;  
     if(image.width>0  &&  image.height>0){  
       flag=true;  
       if(image.width/image.height>=  164/112){  
         if(image.width>164){      
         ImgD.width=164;  
         ImgD.height=(image.height*164)/image.width;  
         }else{  
         ImgD.width=image.width;      
         ImgD.height=image.height;  
         }  
         ImgD.alt=image.width+"×"+image.height;  
         }  
       else{  
         if(image.height>112){      
         ImgD.height=112;  
         ImgD.width=(image.width*112)/image.height;            
         }else{  
         ImgD.width=image.width;      
         ImgD.height=image.height;  
         }  
         ImgD.alt=image.width+"×"+image.height;  
         }  
       }  
}   
//-->  
</script>  

图片调用  
<a  href="<%=trim(rs("picurl"))%>"  target="_blank"><img  src="<%=trim(rs("imgurl"))%>"  border="0"  width="164"  height="112"  onload="javascriptrawImage(this);"></a>  

这样可以实现等比例缩放!

TOP

用VBScript实现代码如何写呢?谁知道啊!

TOP

发新话题