I know I can detect an error like this..
img.onerror = function() {
console.log('error');
}
But is there a way to make something happen only if no errors were found?
EDIT: specifically I'm trying to link an img from a different source
var img = new Image();
img.src = 'link';
is there a way to detect if the link is found then append it to body ONLY if it's found?