Best way to detect missing images from javascript?

Hi

I have a rails app where I need to display images coming from other
sites.

Does anyone have an effective solution to detect missing images (ie
broken
links) in javascript ?

thanks

Thibaut

I have a rails app where I need to display images coming from other sites.

Does anyone have an effective solution to detect missing images (ie broken
links) in javascript ?

My memory is you can load it up doing something like:

i = new Image;
i.src = “http://…”;

then check for the resulting size if it’s width or height is zero, it
isn’t there… and I think there’s a loaded() and maybe other functions
as
well…

search for javascript image methods on google and see what comes up…

Hi Philip

thanks for your answer. I finally found this which seems to work just
fine:

thanks for the pointer!

Thibaut