Help with JavaScript For Loops and iFrames Please!!

Discussion in 'HTML & Website Design' started by wellmoon, Dec 11, 2006.

  1. #1
    Hi,

    I want to load a series of pages into an iFrame and then do something with the contents. The following code works fine with just one page loaded into the iFrame:
    
    function loadDocs() {
        frames("docframe").location.href = docs[0];
        setTimeout("doNextFunction();", 1000);
    }
    
    Code (markup):
    Like I say, this works fine and calls the next function after ample time for the iFrame doc to load. However, docs is an array and as soon as I put the above code into a for loop so that all items in the array can be loaded (one after the other with doNextFunction() acting on all of them), it stops working. This is what I have tried:
    
    function loadDocs() {
      for (x = 0; x < docs.length; x++) {
        frames("docframe").location.href = docs[x];
        setTimeout("doNextFunction();", 1000);
      }
    }
    
    Code (markup):
    Anyone see what I'm doing wrong? Any pointers would be *hugely* appreciated
     
    wellmoon, Dec 11, 2006 IP