1、按照你的要求,则在img tag 的onload事件中使用js处理重新设置大小即可。
2、不按照你的要求,则很多网站是给图片生成一个thumbNail图标,这样更快更方便。对于1,可参照:
<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>=500/400){
if(image.width>500){
ImgD.width=500;
ImgD.height=(image.height*400)/image.width;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
}
else{
if(image.height>400){
ImgD.height=400;
ImgD.width=(image.width*500)/image.height;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
}
}
}
</script> <IMG src="<%=rs("pic")%>" border=0 onload="javascript:DrawImage(this);" >
2、不按照你的要求,则很多网站是给图片生成一个thumbNail图标,这样更快更方便。对于1,可参照:
<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>=500/400){
if(image.width>500){
ImgD.width=500;
ImgD.height=(image.height*400)/image.width;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
}
else{
if(image.height>400){
ImgD.height=400;
ImgD.width=(image.width*500)/image.height;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
}
}
}
</script> <IMG src="<%=rs("pic")%>" border=0 onload="javascript:DrawImage(this);" >
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货