title: How to check if a frame is loaded using javascript? - not onload, not iframe
body: <p><strong>The problem</strong>:  Older knowledgebase software that, for whatever reason, has links that are broken.  It is a series of nested frames.  Some point to the correct target, some do not, and many are just broken.  It makes using the knowledgebase cumbersome when it doesn't work smoothly</p>
  
  <p><strong>What I'm trying to acomplish</strong>:  I want to determine when the specific frame has loaded and then parse the frame's document replacing the anchor tags with correct hrefs and targets.</p>
  
  <p><strong>Resources and limitations</strong>:  I have access to some of the .aspx pages.  The one I'm targeting now contains a framset which loads the knowledgebase document.  The src of this frame however does not appear to be an actual .aspx page (physical file) - unsure how it is generated and unsure how the documents are stored.  I see the src listed but can't find it on the webserver to which I have access. </p>
  
  <p><strong>Basic info:</strong> Pages are loaded using .aspx (I don't understand parts of this well and don't have access to anything much deeper).  The .aspx page has a frameset that gets built when the page is loaded.  </p>
  
  <p>Sample Framset code from the .aspx file:</p>
  
  <pre><code>    &lt;FRAMESET id="FrameSetMainView" runat="server" border="0" framespacing="0" frameborder="0"&gt;
      &lt;!-- This frame set is defined and generated in the code --&gt;
      &lt;/FRAMESET&gt;
  </code></pre>
  
  <p>I've tried adding onload in the <code>FRAMESET</code> tag (this causes the page to error when trying to load).  The frameset takes over the body so I can't add inline script to the bottom of the page to make it run after loading either.</p>
  
  <p>Additionally, b/c of the age of the product - it is forced into compatibility mode.  So IE7 equivalent support has to be used.  (no <code>addeventlistener</code> option)</p>
  
  <p><strong>Current Strategy:</strong>  What I think I can get working, but feels gimicky as all be - adding script into the <code>&lt;head&gt;</code>.  Something along the lines of:</p>
  
  <pre><code>    &lt;SCRIPT&gt;
      function load(){
          var frameset = window.frames;
          if(frameset.length &gt; 0){ // frames have loaded - commence replacement
  
          }else{ // frames not loaded
              setTimeout(load,1000); // wait 1 sec, try again
          }
      }
  
      load();
      &lt;/SCRIPT&gt;
  </code></pre>
  
  <p>Other solutions?</p>