这个东西用JS脚本很方便的啊!
<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>= 140/180){
if(image.width>140){
ImgD.width=140;
ImgD.height=(image.height*140)/image.width;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
/*ImgD.alt=image.width+"×"+image.height;*/
}
else{
if(image.height>180){
ImgD.height=180;
ImgD.width=(image.width*180)/image.height;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
/*ImgD.alt=image.width+"×"+image.height;*/
}
}
/*else{
ImgD.src="";
ImgD.alt=""
}*/
}
</script>
在图片上加载这个事件:
如:<img src="test.jpg" onload='javascript:DrawImage(this);' border="0" class="hui_border">
<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>= 140/180){
if(image.width>140){
ImgD.width=140;
ImgD.height=(image.height*140)/image.width;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
/*ImgD.alt=image.width+"×"+image.height;*/
}
else{
if(image.height>180){
ImgD.height=180;
ImgD.width=(image.width*180)/image.height;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
/*ImgD.alt=image.width+"×"+image.height;*/
}
}
/*else{
ImgD.src="";
ImgD.alt=""
}*/
}
</script>
在图片上加载这个事件:
如:<img src="test.jpg" onload='javascript:DrawImage(this);' border="0" class="hui_border">
我们做软件的口号就是:“为人民服务!”