用Javascript判断图片是否存在,不存在则显示默认图片

<xmp>
<img src="http://www.iecn.net/images/logo_home.gif" onerror="javascript:this.src='http://www.cnlei.org/BLOG/styles/style2007/images/logo.gif'" />
</xmp>
<img src="http://www.iecn.net/images/logo_home.gif" onerror="javascript:this.src='http://www.cnlei.org/BLOG/styles/style2007/images/logo.gif'" /></p>
<p>第二种情况:图片不存在,显示默认图片<br />
<xmp>
<img src="http://www.iecn.net/images/logo_homeAAA.gif"
onerror="javascript:this.src='http://www.cnlei.org/BLOG/styles/style2007/images/logo.gif'" />
</xmp>
<img src="http://www.iecn.net/images/logo_homeAAA.gif" onerror="javascript:this.src='http://www.cnlei.org/BLOG/styles/style2007/images/logo.gif'" /></p>
posted @ 2009-10-07 13:08  waynecn  阅读(823)  评论(0编辑  收藏  举报