ASP中如何控制图片大小,(如何实现等比缩放)?
---------------------------------------------------------------
放入head里面
1<script language="JavaScript">
2<!--
3var flag=false;
4function DrawImage(ImgD){
5var image=new Image();
6image.src=ImgD.src;
7if(image.width>0 && image.height>0){
8flag=true;
9if(image.width/image.height>= 164/112){
10if(image.width>164){
11ImgD.width=164;
12ImgD.height=(image.height*164)/image.width;
13}else{
14ImgD.width=image.width;
15ImgD.height=image.height;
16}
17ImgD.alt=image.width+"×"+image.height;
18}
19else{
20if(image.height>112){
21ImgD.height=112;
22ImgD.width=(image.width*112)/image.height;
23}else{
24ImgD.width=image.width;
25ImgD.height=image.height;
26}
27ImgD.alt=image.width+"×"+image.height;
28}
29}
30}
31//-->
32</script>
图片调用
1<a ```"="" href="```
2=trim(rs(" picurl"))="" target="_blank"><img ```"="" border="0" height="112" imgurl"))="" onload="javascript:DrawImage(this);" src="```
3=trim(rs(" width="164"/></a>
这样可以实现等比例缩放!