title: Correct way to create a HTML page from an empty SVG document
body: <p>I have an extension I use privately that on occasion needs turn a svg document to a html document.</p>
  
  <p>If I detect that the page does not contain a body element and that the <code>location.href</code> contains the text  ".svg" (the document is a SVG document) I try the following</p>
  
  <pre><code>document.removeChild(document.firstChild);
  var body = document.createElement("body")
  var html = document.createElement("html");
  html.appendChild(document.createElement("head"));
  html.appendChild(body);
  document.appendChild(html);
  </code></pre>
  
  <p>Which seems to work. Inspecting the page shows a standard document</p>
  
  <pre><code>&lt;html&gt;
     &lt;head&gt;&lt;/head&gt;
     &lt;body&gt;&lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>But when I try to access <code>document.body.style</code> I get a null referance error. <code>document.body</code> is equal to <code>null</code> Fair enough I then try to set the <code>document.body</code> element directly with</p>
  
  <pre><code>// leading on from first snippet
  document.body = body;  // line 8712
  </code></pre>
  
  <p>and I get a <code>Uncaught TypeError: Failed to set the 'body' property on 'Document': The provided value is not of type 'HTMLElement'.
      at contentscript.js:8712</code></p>
  
  <p>I just can not seem to create a useable HTML document from an empty document. 
  Is it possible? </p>
  
  <p>I really need the page as redirecting will remove the domain and associated session.</p>