没有图片的显示默认图片,限制图片尺寸 代码
1.找不到图片,则显示默认图
<td><IMG src="../images/skin/<%=BoardStyle%>/preview.gif" onerror="javascript:this.src='../images/skin/preview.gif'" width="400" height="300"></td>
2.固定宽度
<img src= "image/index.jpg " onload= "javascript:if(this.width> 500) this.width=500; ">
3.限制图片长宽
function changeImg(obj,width,height) { if ( obj.width > width || obj.height > height ) { var scale; var scale1 = obj.width / width; var scale2 = obj.height / height; if(scale1 > scale2){ scale = scale1; }else{ scale = scale2; } obj.width = obj.width / scale; obj.height = obj.height / scale; }}---------------使用例子<img src="xx.jpg" onload="changeImg(this,180,180)">