用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>

你可能感兴趣的:(JavaScript)