按比例输出,不会令图片变形!<br><br>代码如下<br><br><table width="90%" cellspacing="1" cellpadding="0" border="0" class="ubb_code"><tbody><tr>
<td><script language="JavaScript"> <br>function showimage(imageUrl,size,id) { <br>var imgObj = new Image() <br>imgObj.src = imageUrl; <br>if (id==""){ id="" } <br>if (id==1){ id=" align=left" } <br>if (id==2){ id=" align=right" } <br>if (id==3){ id=" align=absmiddle" } <br>if(imgObj.width > imgObj.height) { <br>incp("<img hspace=4 src="+imgObj.src+" id=infoPicture height=" + imgObj.height*size/imgObj.width + " width=" + size + ""+id+" />"); <br>} else if(imgObj.width < imgObj.height) { <br>incp("<img hspace=4 src="+imgObj.src+" id=infoPicture height=" + size + " width="+ imgObj.width*size/imgObj.height +""+id+" />"); <br>} else { <br>incp("<img hspace=4 src="+imgObj.src+" id=infoPicture height=" + size + " width="+ size + ""+id+" />"); <br>} <br>} <br></script><br>
</td>
</tr></tbody></table>
<br><br>调用:<br><br><script language="JavaScript">showimage('图片路径',宽度数值,位置设置);</script><br><br>位置说明:1 = 左对齐<br><br>2 = 右对齐<br><br>3 = 绝对中间
<td><script language="JavaScript"> <br>function showimage(imageUrl,size,id) { <br>var imgObj = new Image() <br>imgObj.src = imageUrl; <br>if (id==""){ id="" } <br>if (id==1){ id=" align=left" } <br>if (id==2){ id=" align=right" } <br>if (id==3){ id=" align=absmiddle" } <br>if(imgObj.width > imgObj.height) { <br>incp("<img hspace=4 src="+imgObj.src+" id=infoPicture height=" + imgObj.height*size/imgObj.width + " width=" + size + ""+id+" />"); <br>} else if(imgObj.width < imgObj.height) { <br>incp("<img hspace=4 src="+imgObj.src+" id=infoPicture height=" + size + " width="+ imgObj.width*size/imgObj.height +""+id+" />"); <br>} else { <br>incp("<img hspace=4 src="+imgObj.src+" id=infoPicture height=" + size + " width="+ size + ""+id+" />"); <br>} <br>} <br></script><br>
</td>
</tr></tbody></table>
<br><br>调用:<br><br><script language="JavaScript">showimage('图片路径',宽度数值,位置设置);</script><br><br>位置说明:1 = 左对齐<br><br>2 = 右对齐<br><br>3 = 绝对中间