title: JavaScript within <script> tags are not being executed in an iframe
body: <p>I am building a simple online HTML IDE where students can type HTML into a codemirror editor and then when a button is clicked, the HTML is placed in an iframe to render the page.</p>
  <p>My code in question:</p>
  <pre><code>function runit() { 
     var prog = myCodeMirror.getValue(); 
     var mypre = document.getElementById(&quot;output&quot;);
     mypre.contentDocument.body.outerHTML = prog; 
   
  }
  </code></pre>
  <p><code>prog</code> is the html from the editor, <code>mypre</code> is the iframe.</p>
  <p>All html placed within <code>&lt;body&gt;</code> tags is correctly executed in the iframe.
  All css code placed within <code>&lt;style&gt;</code> tags is correctly executed in the iframe.
  However, any javascript placed within <code>&lt;script&gt;</code> tags is not executed in the iframe.</p>
  <p>How can I get <code>&lt;script&gt;</code> tag contents to be correctly executed in the iframe?</p>