<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>= 170/110){
if(image.width>170){
ImgD.width=170;
ImgD.height=(image.height*170)/image.width;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
ImgD.alt=image.width+"×"+image.height;
}
else{
if(image.height>110){
ImgD.height=110;
ImgD.width=(image.width*110)/image.height;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
ImgD.alt=image.width+"×"+image.height;
}
}
}
//-->
</script>
调用事例如:<IMG width=170 height=110 src='"&rs("IndexPicUrl")&"'οnlοad='javascript:DrawImage(this);' border=0>
只需要改变你需要的图片大小即可宽度170,高度110
<!--
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>= 170/110){
if(image.width>170){
ImgD.width=170;
ImgD.height=(image.height*170)/image.width;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
ImgD.alt=image.width+"×"+image.height;
}
else{
if(image.height>110){
ImgD.height=110;
ImgD.width=(image.width*110)/image.height;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
ImgD.alt=image.width+"×"+image.height;
}
}
}
//-->
</script>
调用事例如:<IMG width=170 height=110 src='"&rs("IndexPicUrl")&"'οnlοad='javascript:DrawImage(this);' border=0>
只需要改变你需要的图片大小即可宽度170,高度110