Missing text

C

chirs

I have a small code. It does not print the word "hi". Why?

<HEAD>
<SCRIPT language=JavaScript>
function listnum() {
i=0
do {
document.write( i + "<br>")
i++
} while(i<10)
}</SCRIPT>
</HEAD>

<BODY onload=listnum()>
hi
</BODY>

Thank you.
 
E

Evertjan.

chirs wrote on 12 sep 2003 in comp.lang.javascript:
I have a small code. It does not print the word "hi". Why?

<HEAD>
<SCRIPT language=JavaScript>
function listnum() {
i=0
do {
document.write( i + "<br>")
i++
} while(i<10)
}</SCRIPT>
</HEAD>

<BODY onload=listnum()>
hi
</BODY>

Thank you.

Because you cannot do a document.write on a page without destroying the
page that was there before.
 
S

sales

chirs wrote on 12 sep 2003 in comp.lang.javascript:


Because you cannot do a document.write on a page without destroying the
page that was there before.

NOT quite true! Try this:
<html>
<head><script language="JavaScript">
function listnum() {
i=0
do {
document.write( i + "<br>")
i++
} while(i<10)
}</script>
</head>
<body>
<p>hi </p>
<script language="JavaScript">
listnum()
</script>
<p>AND hi AGAIN....</p>
</body>
</html>



Dave Walker

For PHP and MySQL demo try here:
http://www.thedemosite.co.uk -- hey its free.
Seiretto for Hosting Solutions that Work.
http://www.Seiretto.com
 
L

Lasse Reichstein Nielsen

On 12 Sep 2003 19:17:39 GMT, "Evertjan."
NOT quite true!

Correct. The quite true version is:

Because you cannot do a document.write on a page that has finished
loading, without destroying the page that was there before.

/L
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top