You can use the error
event:
var im = document.getElementById('imageID'); // or select based on classes
im.onerror = function(){
// image not found or change src like this as default image:
im.src = 'new path';
};
Inline Version:
<img src="whatever" onError="this.src = 'new default path'" />
Or
<img src="whatever" onError="doSomething();" />
<img>
tag supports these events:
abort
(onAbort)
error
(onError)
load
(onLoad)
More Information:
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…