I'm loading images from a server which returns images when there is a 404. That is, if the image I'm loading doesn't exist, the server will return a 404 response with a 200x200 PNG fallback image that says "photo not available" on it.
I would like to detect the times when this happens client-side. I tried the onerror
attribute:
<img src="http://ift.tt/1lgTX7A" onerror="console.log(this)" />
This code only works when the 404 response from the server has no image at all. Since my 404 response does, the onerror
event is never fired.
Is there a way around this problem, short of pre-loading images with JavaScript?
Aucun commentaire:
Enregistrer un commentaire