Connecting Tech Pros Worldwide Help | Site Map

body onload executing after script element?

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2006, 04:45 AM
yawnmoth
Guest
 
Posts: n/a
Default body onload executing after script element?

<body onload="alert('test')">
<script>location = "http://www.google.com"</script>
</body>

....and...

<body onload="alert('test')"></body>
<script>location = "http://www.google.com"</script>

It seems to me as though an alert window containing the word 'test'
ought to appear before the page is redirected to Google yet it isn't.
Any ideas as to why?


  #2  
Old July 17th, 2006, 01:25 PM
Sevinfooter
Guest
 
Posts: n/a
Default Re: body onload executing after script element?

also, there should be a semicolon after the alert method

alert("BLAH BLAH");

  #3  
Old July 17th, 2006, 01:45 PM
Richard Cornford
Guest
 
Posts: n/a
Default Re: body onload executing after script element?

Sevinfooter wrote:
Quote:
also, there should be a semicolon after the alert method
>
alert("BLAH BLAH");
That would be "should" in the sense of ; there is no necessity to
insert a semicolon at that point because automatic semicolon insertion
will do it for you, and any instruction to insert such a semicolon
represent no more than a style preference (even if a common one).

Richard.

  #4  
Old July 17th, 2006, 02:45 PM
Sevinfooter
Guest
 
Posts: n/a
Default Re: body onload executing after script element?


Richard Cornford wrote:
Quote:
Sevinfooter wrote:
Quote:
also, there should be a semicolon after the alert method

alert("BLAH BLAH");
>
That would be "should" in the sense of ; there is no necessity to
insert a semicolon at that point because automatic semicolon insertion
will do it for you, and any instruction to insert such a semicolon
represent no more than a style preference (even if a common one).
>
Richard.
All I'm saying, is that it works for me with <body
onload="alert("blah");">

  #5  
Old July 17th, 2006, 03:05 PM
Richard Cornford
Guest
 
Posts: n/a
Default Re: body onload executing after script element?

Sevinfooter wrote:
Quote:
Richard Cornford wrote:
Quote:
>Sevinfooter wrote:
Quote:
>>also, there should be a semicolon after the alert method
>>>
>>alert("BLAH BLAH");
>>
>That would be "should" in the sense of ; there is no necessity to
>insert a semicolon at that point because automatic semicolon
>insertion will do it for you, and any instruction to insert such a
>semicolon represent no more than a style preference (even if a
>common one).
>
All I'm saying, is that it works for me with
<body onload="alert("blah");">
In what sense "works" (considering that the expected behaviour has been
being exhibited from the outset), and how does that "works" differ from
what happens without the semicolon?

Richard.

  #6  
Old July 17th, 2006, 03:05 PM
Sevinfooter
Guest
 
Posts: n/a
Default Re: body onload executing after script element?

About the problem, what I recommend is that you wrap it all in a
function:

<body onload="someFunction();">
<script>
function someFunction() {
alert("your message");
location="http://www.google.com";
}
</script>

Cheers,

Mark

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.