title: Get source from HTML created by JavaScript
body: <p>I'm working on a simple web form for teachers in my building to generate HTML pages with embedded videos to use locally (our substitutes can't get on the Internet to play videos; this is a workaround).</p>
  
  <p>I'm using a script to take parameters from a form and dynamically build the HTML. I know the server is building the page, not the client, but is there no way for them to save the source?</p>
  
  <p>I tried accessing the content with <code>document.getElementById('main').innerHTML</code>, but because there's no information in the DOM, it returns an error.</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;script type="text/javascript"&gt;
  function createNewWindow () {
    var userName = document.getElementById('user_name').value
    var videoSrc = document.getElementById('video_src').value
    var newPage = "&lt;html&gt;&lt;head&gt;&lt;link rel='stylesheet' type='text/css' media='screen' href='style.css' /&gt;&lt;title&gt;"
    newPage += userName;
    newPage += "&lt;/title&gt;&lt;/head&gt;";
    newPage += "&lt;body&gt;&lt;div id='main'&gt;&lt;div id='content'&gt;&lt;div class='video'&gt;";
    newPage += "&lt;video controls&gt;&lt;source src='" + videoSrc;
    newPage += "' type='video/webm'/&gt;";
    newPage += "&lt;/video&gt;&lt;/div &lt;!--video--&gt;&gt;"
    newPage += "&lt;input type='submit' value='Get Code' onclick='alert(document.getElementById(main).innerHTML);'"
    newPage += "&lt;/body&gt;&lt;/html&gt;";
    var j = window.open('');
    j.document.write(newPage);
    j.document.close();
  }
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form action=""&gt;
  &lt;p&gt;
  User name: &lt;input type="text" id="user_name"&gt;
  Video file: &lt;input type="text" id="video_src"&gt;
  &lt;input type="submit"
    value="Create new page"
    onclick="createNewWindow();"
    &gt;
  &lt;/p&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I first tried using <code>execCommand</code> to download the content, but running command-level scripts on school computers is blocked, so the solution <a href="https://stackoverflow.com/questions/3223915/how-to-open-and-save-text-in-html-to-a-file-using-javascript-in-html">described in this SO post</a> won't work for me.</p>
  
  <p>I'm stuck on finding a simple way for non-programmers to save the generated page as HTML easily (avoiding Inspect Element, Firebug, etc). Any ideas?</p>