<img cg width="100" height="100" alt='<%= model.model.Topic %>' src='<%=imgpath+"/"+model.model.Face %>h' onerror='this.src="/Styles/Expert/images/default120.gif"'/>
我这样写在ie与ff里都起作用<img cg width="100" height="100" alt='<%= model.model.Topic %>' src='<%=imgpath+"/"+model.model.Face %>h'/>
$(function() {
$("img[cg]").attr("onerror", 'javascript:this.src="/Styles/Expert/images/default120.gif"');
});
我用js里写在ie里就不行,在ff里有些页面可以,有些页面不可以。
另外,如果src为空的话,好像也不会触发 onerror事件。。
请问要怎样解决?
我这样写在ie与ff里都起作用<img cg width="100" height="100" alt='<%= model.model.Topic %>' src='<%=imgpath+"/"+model.model.Face %>h'/>
$(function() {
$("img[cg]").attr("onerror", 'javascript:this.src="/Styles/Expert/images/default120.gif"');
});
我用js里写在ie里就不行,在ff里有些页面可以,有些页面不可以。
另外,如果src为空的话,好像也不会触发 onerror事件。。
请问要怎样解决?
ele.src = "http://cm.aqioo.com/Styles/Expert/images/default120.gif";
}
<img cg width="100" height="100" alt='<%= model.model.Topic %>' src='<%=imgpath+"/"+model.model.Face %>' onerror='showimg(this);' /><br />
这是一种没办法的解决方法。。
请问还有其他吗?
$(function() {
$("img[cg]").attr("onerror", 'this.src="/Styles/Expert/images/default120.gif"');
});
这样看看,去掉javascript:
(csdn社区) 等 级:
结帖率:101.30%
楼主结贴率可以大于100%吗神奇
$("img[cg]").bind("error",function(){
$(this).attr("src","/Styles/Expert/images/default120.gif")
})
而ff就可以。。
难道只能写到标签里面吗?
this.src=yourUrl.
})
里是不行的,可能直接在标签的下面写
就可以。。
时间的加载和绑定的效果是一样的你把js放在html的最后等Dom元素加载完之后 执行绑定
我觉得在ie里 img 的onerror 事件比 onload事件还要早。
不知道楼上的是不是这个意思?