Thibaut Barrère
2006-Dec-07 14:41 UTC
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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thibaut Barrère
2006-Dec-07 15:09 UTC
Re: Best way to detect missing images from javascript ?
Hi Philip thanks for your answer. I finally found this which seems to work just fine: <img src="http://example.com/testimage.gif" onerror="this.src = ''error.gif'';"> thanks for the pointer! Thibaut --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Philip Hallstrom
2006-Dec-07 15:14 UTC
Re: Best way to detect missing images from javascript ?
> 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... --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---