<img>标签加入onerror事件,如果没有找到图片,则使用默认图片

来源:互联网 发布:angular数据双向绑定 编辑:程序博客网 时间:2024/06/06 04:08
<span style="font-size:18px;"><img src='"+url+".gif' onerror='nofind();' /></span>
<span style="font-size:18px;"></span>
<span style="font-size:18px;">Js代码如下:</span>
<pre name="code" class="javascript"><span style="font-size:18px;">function nofind(){     var img=event.srcElement;     img.src=rootPath+"/images/gis/030201_4.gif";  //默认图片地址    img.onerror=null; //控制不要一直跳动}</span>


0 0
原创粉丝点击