title: JS export html file code Edit?
body: <p>I'm beginner. I use this code export <code>&lt;div&gt;</code> content to html file, but converter file have not <code>&lt;html&gt;&lt;/html&gt;</code>, <code>&lt;body&gt;&lt;/body&gt;</code>, <code>&lt;head&gt;&lt;/head&gt;</code>. please teach me how to add this code to export file? Thx</p>
  
  <p>Html Code:</p>
  
  <pre><code>&lt;div id="main"&gt;&lt;/div&gt;
  
  &lt;script type="text/javascript"&gt;
          $('#downloadLink').click(function(){
      downloadInnerHtml(fileName, 'main','text/html');
  });
          &lt;/script&gt;
  </code></pre>
  
  <p>JS Code:</p>
  
  <pre><code>function downloadInnerHtml(filename, elId, mimeType) {
  
      var elHtml = document.getElementById(elId).innerHTML;
      var link = document.createElement('a');
  
      mimeType = mimeType || 'text/plain';
  
      link.setAttribute('download', filename);
      link.setAttribute('href', 'data:' + mimeType  +  ';charset=utf-8,' + encodeURIComponent(elHtml));
      link.click();
  }
  
  
  var fileName =  'Filename'+'.html';
  </code></pre>