title: JavaScript - controlling the insertion point for document.write
body: <p>I would like to create a page that runs a 3rd party script that includes <code>document.write</code> after the DOM was already fully loaded.</p>
  
  <p>My page is not XHTML. My problem is that the document.write is overwriting my own page. (which is what it does once the DOM was loaded).</p>
  
  <p>I tried overriding the document.write function (in a way similiar to <a href="http://ejohn.org/blog/xhtml-documentwrite-and-adsense/" rel="noreferrer">http://ejohn.org/blog/xhtml-documentwrite-and-adsense/</a>) but that doesn't cover cases where the document.write contains partial tags.</p>
  
  <p>An example that would break the above code is:</p>
  
  <pre><code>document.write("&lt;"+"div");
  document.write("&gt;"+"Done here&lt;"+"/");
  document.write("div&gt;");
  </code></pre>
  
  <p>Is there some way to modify the document.write insertion point through JavaScript? Does anyone have a better idea how to do this?</p>