Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Order of execution

Reply
Thread Tools

Order of execution

 
 
chirs
Guest
Posts: n/a
 
      09-15-2003
I have a small code. It prints 0,1,...,9, but you cannot see the word
"hi". It seems that it prints "hi" then executes the listnum
function. But the listnum function is placed before "hi". Could you
give me some info on order of execution?

<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.
 
Reply With Quote
 
 
 
 
Vjekoslav Begovic
Guest
Posts: n/a
 
      09-15-2003
"chirs" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) m...
> I have a small code. It prints 0,1,...,9, but you cannot see the word
> "hi". It seems that it prints "hi" then executes the listnum
> function. But the listnum function is placed before "hi". Could you
> give me some info on order of execution?
>
> <HEAD>
> <SCRIPT language=JavaScript>
> function listnum() {
> i=0
> do {
> document.write( i + "<br>")
> i++
> } while(i<10)
> }</SCRIPT>
> </HEAD>
>
> <BODY onload=listnum()>
> hi
> </BODY>


The onLoad event handler triggers when a page finishes loading. When you
document.write on such a page, you destroy the previous page. You could try
the following:

<body>
<script type="text/javascript">
listnum();
</script>
hi
</body>

HTH

Vjekoslav


 
Reply With Quote
 
 
 
 
JB
Guest
Posts: n/a
 
      09-18-2003
Try this,
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title></title>
</HEAD>
<BODY>
Hi<br>
<SCRIPT language=JavaScript>
{
i=0
do {
document.write( i + "<br>")
i++
} while(i<10)
}</SCRIPT>
</BODY>
</html>
------------------------------------------------------

"Vjekoslav Begovic" <(E-Mail Removed)> wrote in message
news:bk53os$jqm$(E-Mail Removed)...
> "chirs" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) m...
> > I have a small code. It prints 0,1,...,9, but you cannot see the word
> > "hi". It seems that it prints "hi" then executes the listnum
> > function. But the listnum function is placed before "hi". Could you
> > give me some info on order of execution?
> >
> > <HEAD>
> > <SCRIPT language=JavaScript>
> > function listnum() {
> > i=0
> > do {
> > document.write( i + "<br>")
> > i++
> > } while(i<10)
> > }</SCRIPT>
> > </HEAD>
> >
> > <BODY onload=listnum()>
> > hi
> > </BODY>

>
> The onLoad event handler triggers when a page finishes loading. When you
> document.write on such a page, you destroy the previous page. You could

try
> the following:
>
> <body>
> <script type="text/javascript">
> listnum();
> </script>
> hi
> </body>
>
> HTH
>
> Vjekoslav
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
private data stashed in local/global execution context of PyEval_EvalCode disappears down the execution stack sndive@gmail.com Python 9 11-14-2007 10:31 PM
doubt in FLI Program and order of execution priya VHDL 0 10-03-2005 12:55 PM
Re: A question about order of execution? John Saunders ASP .Net 2 07-15-2004 06:44 PM
Execution order of Validation Controls Bijoy Naick ASP .Net 1 06-08-2004 04:31 PM
Execution order of PageLoad for user controls =?Utf-8?B?QmlsbCBCb3Jn?= ASP .Net 2 03-06-2004 03:01 PM



Advertisments