It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

Problem with document.write()

Problem with document.write()

Postby DrAmbar on Mon Sep 04, 2006 9:49 am

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
DrAmbar
 
Posts: 2
Joined: Mon Sep 04, 2006 9:30 am

Who is online

Users browsing this forum: No registered users and 3 guests