複製程式碼如下:
<腳本語言=“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>