1

I'd like to replace broken images with default one in a image gallery. I use jQuery to do this:

<img src="#{articleController.getArticleMainImageLink(index)}" 
     class="articleImage" alt="#{msg['no.image.data']}" />

<script type="text/javascript">
    $(document).ready(function () {
        $("img.articleImage").on("error", function(){
            $(this).attr("src", "http://images5.fanpop.com/image/photos/28900000/Adriana-Lima-adriana-lima-28919058-1280-1024.jpg");
        })
    });
</script>

The problem is that the default images do not appear immediately after page reload but after about two minutes (browser timeout?) (tested with Firefox 31, Safari 6.1.6). Is there any way to resolve this problem?

Alex
  • 111
  • 1
  • 1
  • 3
  • That is not a duplicate of https://stackoverflow.com/questions/92720/jquery-javascript-to-replace-broken-images, because first their solution doesn't work for me and second I'd like to know how to reduce error event timeout – Alex Aug 15 '14 at 13:35
  • @j08691 Can you remove the duplicate label please? I explained the reason in the comment above. – Alex Aug 15 '14 at 14:27

0 Answers0