复制代码代码如下:
<脚本语言=“JavaScript”>
函数 DrawImage(ImgD,FitWidth,FitHeight){
var image=new Image();
image.src=ImgD.src;
if(图像宽度>0 && 图像高度>0){
if(image.width/image.height>= FitWidth/FitHeight){
if(image.width>FitWidth){
ImgD.width=FitWidth;
ImgD.height=(image.height*FitWidth)/image.width;
}
别的{
ImgD.width=图像.width;
ImgD.height=图像.高度;
}
}
别的{
if(image.height>FitHeight){
ImgD.height=FitHeight;
ImgD.width=(image.width*FitHeight)/image.height;
}
别的{
ImgD.width=图像.width;
ImgD.height=图像.高度;
}
}
}
}
</脚本>
调用方法:
复制代码代码如下:
<a href="admin/<? echo $rscase['path']?>" target="_blank"><img src="admin/<? echo $rscase['path']?>" onload='javascript :DrawImage(这个,180,);' hspace="3" vspace="3" /></a>