Why is code after document.write() not executed?
<p>I have the follwing JavaScript. </p>

<pre><code>&lt;html&gt;
    &lt;head&gt;
        &lt;script language="JavaScript"&gt;
            function fdivisible()
            {
                document.write("&lt;h1&gt; Just a javascript demo&lt;/h1&gt;");
                var x=document.forms["aaa"]["txt1"].value;  
                alert(x);   
            }
        &lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;form action="#" name="aaa"&gt;
            Enter a no. : &lt;input type="text" name="txt1" id="txt1" /&gt;
            &lt;input type="button" value="Click" onclick="fdivisible();"&gt;
        &lt;/form&gt;
    &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>The problem is, the first line of the JS function is executing and the rest are ignored. If I comment out the first line the rest of the code is executed. Can anybody explain to me why it is so?</p>
