ASP控制图片显示的大小的例子

王朝网络·asp·作者佚名  2006-11-24
宽屏版  字体: |||超大  

<HTML>

<HEAD>

<TITLE> New Document </TITLE>

<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+"x"+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+"x"+image.height;

}

}

}

//-->

</script>

</HEAD>

<BODY>

<a href="./img.jpg" target="_blank"><img src="./img.jpg" border="0" width="164" height="112" onload="javascript:DrawImage(this);"></a>

</BODY>

</HTML>

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有