Is it possible to detect when an image does not load using JavaScript? I plan to use base64 for images, but browsers like IE 6 and 7 do not support it. So instead of displaying red x, I would like to detect such an error, and then display the image without base64. The following is an example of my intentions:
PHP $base64Img = base64 String; print("<img src=\"data:image/jpeg; base64, ".$base64Img."\" />"); JavaScript IE 6 catch img load error{ errorImg.src = "ieSafeImg.jpg"; }
source share