+ Reply to Thread
Results 1 to 1 of 1

Thread: JavaScript makes me mad!

  1. #1
    Twinkie is offline Banned Twinkie is an unknown quantity at this point
    Join Date
    Sep 2007
    Location
    Ft. Lauderdale, Florida
    Posts
    1,389

    JavaScript makes me mad!

    I have a school project where I decided to make a web site quiz on book 10 of the odyssey. I like to do a nice job, so I threw some image fading effects and interactivity, but it's having some errors I don't have the time to fix! Why is this function freezing in the middle of the image preload (sometimes, not sure in what circumstances)?? ='(
    Code:
    var c = 0, b = 0, t;
    function ImagePreload() {
      var total = (quiz.getElementsByTagName("img1").length) + (quiz.getElementsByTagName("img2").length);
      $("loading").innerHTML = "Loading "+ Math.round(100*((c+b)/total)) + "%";
      if (quiz.getElementsByTagName("img1").length > c) {
        var image1 = new Image();
        image1.onabort=ImagePreload;
        image1.onload=ImagePreload;
        image1.src = quiz.getElementsByTagName("img1")[c++].childNodes[0].nodeValue;
      } else if (quiz.getElementsByTagName("img2").length > b) {
        var image2 = new Image();
        image2.onabort=ImagePreload;
        image2.onload=ImagePreload;
        image2.src = quiz.getElementsByTagName("img2")[b++].childNodes[0].nodeValue;
      } else {
        $("loading").style.display="none";
        NextQuestion();
        return false;
      }
      return false;
    }
    Assuming that the variable quiz is an xml document, and that I am sure the loading bar ends at 100%, whats wrong with it?

    Also, if you go through the quiz, the left image fades into the previous image and then switches to the next image in just one question. Quite an odd error because both groups of images are treated the same, and the error is consistent in IE 7 with different images. Any ideas please?

    PS: It's due tomorrow so thanks for your help

    Edit:
    Thanks anyways... I can't close the thread.
    Last edited by Twinkie; 03-03-2009 at 09:19 PM. Reason: Automerged Doublepost

+ Reply to Thread

Similar Threads

  1. Making a site JavaScript dependent - pros/cons?
    By Tarzan in forum Programming Help
    Replies: 8
    Last Post: 07-11-2008, 10:08 AM
  2. drop down menus with JavaScript disabled?
    By sifaka in forum Free Hosting
    Replies: 1
    Last Post: 05-15-2008, 10:46 AM
  3. javascript and external javascript files problem
    By delon in forum Programming Help
    Replies: 6
    Last Post: 04-27-2008, 12:41 AM
  4. XML and Javascript
    By cuteboytm in forum Graphics & Webdesign
    Replies: 1
    Last Post: 09-21-2007, 10:00 AM
  5. Some nice-simple JavaScript effects !!
    By careerbridge in forum Scripts & 3rd Party Apps
    Replies: 1
    Last Post: 07-13-2006, 08:36 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers