Results 1 to 3 of 3

Thread: Is there any way to handle multiple photo errors in sequence?

  1. #1
    Join Date
    Mar 2010

    Is there any way to handle multiple photo errors in sequence?


    I am working on connecting a web application to a folder of photos that has some photos named with their "master" attribute (e.g. folder/master.JPG) and others named with their "name" attribute. I can't change the name of these photos.

    I want to be able to check first the "master" attribute, then the "name" attribute, and then display a "no photo available" image if trying both attributes resulted in an error. However, I'm not sure why I can't get to the "no photo available" part.

    Here's what I am trying (hopefully the other parts of the code are self-explanatory):

    function selectionEvent() {
       var link = PHOTO_PATH + masterSelected + ".JPG";
       document.getElementById('Image').onError = masterError;
       document.getElementById('Image').src = link;
    function masterError() {
       var link = PHOTO_PATH + nameSelected + ".JPG";
       document.getElementById('Image').onError = photoError;
       document.getElementById('Image').src = link;
    function photoError() {
       alert ('I never get here');
    The first two functions work fine (photos can be looked up by "master" and "name" names), but selecting a record with no photo results in what I think is an infinite loop. I don't understand why the second function can't get to the third function in case of an error? Do I need to somehow clear the first error first? Or is it something else entirely?

    Thanks in advance for help that anyone can provide!

  2. #2
    Join Date
    Jun 2007
    Event handlers are all lowercase: onerror not onError.
    Y_U U_G_A_E_U_ B_S_A_D_

  3. #3
    Join Date
    Mar 2010
    Wow...that fixed it!

    I have no idea why it was "halfway" working with that problem...but thank you

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center