3

Does every browser behave consistently when getting a HTTP "204 No Content" for an img src request?

<img src="/gives_me_a_204.gif" onError="alert('err')" onLoad="alert('ok')" />

on firefox and opera i get an 'err', want to know if all others browsers will also give me that.

gcb
  • 12,288
  • 7
  • 58
  • 86
  • I don't know, but I wouldn't count on it. Then again, IIRC Google uses it for their tracking pixels. Maybe expand on your real world use case? – Pekka Oct 17 '12 at 21:53
  • Indeed, I remembered correctly. Related: [Google.com and clients1.google.com/generate_204](http://stackoverflow.com/q/1989214) – Pekka Oct 17 '12 at 21:54
  • @Pekka I looked at gmaps code, the image there is used only generate a DNS cache of the domain, so that there's no delay when they send the ajax one. I don't think they use image's onload/onerror for the beacons itself. – gcb Oct 17 '12 at 22:16
  • Ah, okay. I think you should add some more detail about what you are doing, and what behaviour you are expecting. I'm not sure how `onError` would come into play at all when a 204 is served? Either way, this sounds like such an edge case that you probably won't be able to rely on the same behaviour across browsers. But maybe somebody can suggest a workaround for whatever it is you want to do. – Pekka Oct 17 '12 at 22:17

0 Answers0