title: Run script before iframe loads
body: <p>I'm working with a help system which is embedded in an application.</p>
  
  <p>The important part of the help tries to have the same document.domain value, but the child iframe seems to run its document.domain setting before the parent does. This is a problem because it throws a security error and halts javascript execution. Here's basically what the html looks like, to give the proper idea:</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
          &lt;!--Occasionally runs second--&gt;
          &lt;script src="change-document-domain.js"&gt;&lt;/script&gt;
      &lt;/head&gt;
  
      &lt;body&gt;
          &lt;iframe&gt;
              &lt;html&gt;
  
                  &lt;head&gt;
                      &lt;!--Occasionally runs first--&gt;
                      &lt;script src="change-document-domain.js"&gt;&lt;/script&gt;
                  &lt;/head&gt;
  
              &lt;/html&gt;
          &lt;/iframe&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The help is very restricted by the program which builds it. Is there any change I can make to the parent script or parent script tag to make it load before the iframe or its script does?</p>
  
  <p>Let me know if you have any questions, and thanks as always!</p>