title: Can I intercept the loading of an iframe and modify the contentWindow?
body: <p>I am trying to provide a property to an iframe via its contentWindow and would like to do it in a synchronous manner.</p>
  <p>I know I can access and set properties on the <code>contentWindow</code> of the iframe but the modification will occur after the iframe has loaded.</p>
  <p>Parent</p>
  <pre class="lang-html prettyprint-override"><code>&lt;body&gt;
    &lt;script&gt;
      const frame = document.createElement('iframe')
      document.body.appendChild(frame)
      frame.src = 'frame.html'
      frame.contentWindow.foobar = 'foobar'
    &lt;/script&gt;
  &lt;/body&gt;
  </code></pre>
  <p>iframe</p>
  <pre class="lang-html prettyprint-override"><code>&lt;body&gt;
    &lt;script&gt;
      console.log(window.foobar) // undefined
    &lt;/script&gt;
  &lt;/body&gt;
  </code></pre>
  <p>Is it possible to achieve or do I have to do this asynchronously by dispatching an event from the parent notifying the iframe that the property has been set?</p>