Delayed document.write
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/1536970/javascript-controlling-the-insertion-point-for-document-write">JavaScript - controlling the insertion point for document.write</a>  </p>
</blockquote>



<p>I want to delay <code>document.write</code> if block with <code>document.write</code> not in the viewport of browser. 
I tried to make it after window loaded, but <code>document.write</code> replaces the whole content :(</p>

<pre><code>$(function(){
    document.write('bla')
)}
</code></pre>

<p>Also, in this <code>document.write</code> I have script with ads and it must work when added in block. </p>

<p>Is it possible?</p>

<p>UPD: i have code whith <code>document.write</code>, which pushes in document <code>&lt;script&gt;</code>. so, because of this code my page loads very slowly and i want to load this script only when dom is ready or when user srolls to the block where my ads placed</p>
