Connecting Tech Pros Worldwide Help | Site Map

body onload executing after script element?

  #1  
Old July 17th, 2006, 05:45 AM
yawnmoth
Guest
 
Posts: n/a
<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, 02:25 PM
Sevinfooter
Guest
 
Posts: n/a

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, 02:45 PM
Richard Cornford
Guest
 
Posts: n/a

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, 03:45 PM
Sevinfooter
Guest
 
Posts: n/a

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, 04:05 PM
Richard Cornford
Guest
 
Posts: n/a

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, 04:05 PM
Sevinfooter
Guest
 
Posts: n/a

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

Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help gunimpi answers 0 January 10th, 2007 08:55 PM
Element Insertion question Alex answers 3 February 26th, 2006 01:45 AM
DOM doc - simple find element one man army answers 27 January 25th, 2006 07:25 AM
Body tag preventing 'window.open' from executing alanstew answers 8 July 23rd, 2005 11:15 AM