DrAmbar
Joined: 04 Sep 2006 Posts: 2
|
Posted: Mon Sep 04, 2006 10:49 am Post subject: Problem with document.write() |
|
|
Hi,
I'm having trouble understanding the behaviour of the easiest of Javascript commands. Look at this htm file:
<HTML><HEAD>
<Script Language="JavaScript">
function Wrt()
{ document.write("Output of document.write"); }
</Script>
</HEAD><BODY>
<h2>Heading</h2>
<BUTTON onClick="Wrt();">TryIt</BUTTON>
</BODY></HTML>
If you try it out, the Output of document.write erases whatever else was already on the page (which was not the intention) and the mouse cursor shows the hourglass (busy indication) forever. However if the code is written without a button, like this:
<HTML><HEAD></HEAD>
<BODY>
<h2>Heading</h2>
<Script Language="JavaScript">
document.write("Output of document.write")
</Script>
</BODY></HTML>
It works okay.
Can someone tell me what is going on? Thanks in advance.
Ambar |
|