title: Cannot load script into iframe
body: <p><strong>Test page:</strong> <a href="https://jsfiddle.net/y25rk55w/" rel="nofollow noreferrer">https://jsfiddle.net/y25rk55w/</a>  </p>
  
  <p>On this test page you can see 3 <code>&lt;iframe&gt;</code>'s embeded into each other. Each <code>&lt;iframe&gt;</code> contains a <code>&lt;script&gt;</code> tag in it's <code>&lt;head&gt;</code> tag.  </p>
  
  <p><strong>The problem is:</strong> only the <code>&lt;script&gt;</code> in the first <code>&lt;iframe&gt;</code> will be loaded by the browser. The other two <code>&lt;script&gt;</code> tags will be present in the dom but the browser will never even try to load them. The problem is not browser specific, it can be reroduced in chrome, firefox, ie. The problem cannot be fixed by adding timeouts or waiting before appending the scripts. It seems to be important that all the iframes have programatically generated content; if you replace this iframes with iframes with actual src links, the problem will disappear.</p>
  
  <p><strong>The question is:</strong> how can I actually load a script into iframes 2 and 3?</p>
  
  <p><strong>Full test code:</strong></p>
  
  <pre><code>// It doesn't matter if the scripts exist or not
  // Browser won't try to load them either way
  var scripts = [
      '//testdomain.test/script1.js',
      '//testdomain.test/script2.js',
      '//testdomain.test/script3.js'
  ];
  
  function createIFrame(win, onCreated) {
      var iframe = win.document.createElement('iframe');
      iframe.onload = function () {
          onCreated(iframe);
      };
      win.document.body.appendChild(iframe);
  }
  
  function loadScript(win, url) {
      var script = win.document.createElement('script');
      script.src = url;
      script.onload = function() {
          console.log("Script " + url + " is loaded.");
      };
      win.document.getElementsByTagName('head')[0].appendChild(script);
  }
  
  createIFrame(window, function(iframe1) {
      loadScript(iframe1.contentWindow, scripts[0]);
      createIFrame(iframe1.contentWindow, function (iframe2) {
          loadScript(iframe2.contentWindow, scripts[1]);
          createIFrame(iframe2.contentWindow, function (iframe3) {
              loadScript(iframe3.contentWindow, scripts[2]);
          });
      });
  });
  </code></pre>