JS代码(随便放哪里) :
<langage de script="JavaScript">
<!--
var drapeau = faux ;
fonction DrawImage(ImgD){
var image=nouvelle image();
image.src=ImgD.src;
si (image.width>0 && image.height>0){
drapeau = vrai ;
si(image.width/image.height>= 180/110){
si(image.largeur>180){
ImgD.width=180 ;
ImgD.height=(image.height*110)/image.width;
}autre{
ImgD.width=image.width;
ImgD.hauteur=image.hauteur ;
}
/*ImgD.alt="bigpic" */
}
autre{
si(image.hauteur>110){
ImgD.hauteur=110 ;
ImgD.width=(image.width*110)/image.height;
}autre{
ImgD.width=image.width;
ImgD.hauteur=image.hauteur ;
}
/*ImgD.alt="bigpic" */
}
}
}
//-->
</script>
图片使用的地方:
<img src="图片" border=0 width="180" height="110" onload="javascriptrawImage(this);">
width="180" height="110"很难看的.这里是宽度和高度,在前面的JS里改,这里也作相应的改.
图不会变形,只会按比列缩,放心