document.write and delegated event handler persistence
<p>I'm just testing out replacing a whole page with another page using JavaScript and <a href="http://stackoverflow.com/a/1236378/575527">I found this answer</a> with <code>document.write</code>. As to why <code>document.write</code>, I needed to replace the entire HTML, including scripts and styles using the same page.</p>

<p>It does what I want but i can't seem to have consistency with my event handlers. My handlers are all attached to <code>document</code> using:</p>

<pre><code>$(document).delegate(...);
</code></pre>

<p>Currently, I have weird results. <a href="http://jsfiddle.net/wphzt/1/" rel="nofollow">In a fiddle I made,</a> it attaches a handler. When clicked, the event fires, rewrites the page, runs the function again - but it doesn't attach the handler.</p>

<p>However in my project, I'm doing the same routine (<code>d.w()</code>, then add handlers). It does reattach once and handlers work, but after doing a second routine (still on the same page), it doesn't attach anymore.</p>

<p>So my questions are: </p>

<ul>
<li>When using <code>d.w()</code>, do existing handlers get erased from <code>document</code>?</li>
<li>Are <code>window</code> as well as <code>document</code> the same after subsequent <code>d.w()</code>s? or are they somehow "renewed"</li>
<li>Do scripts that are already parsed stay in memory and run after subsequent <code>d.w()</code>s? Or do they get erased as well?</li>
</ul>
