Connecting Tech Pros Worldwide Help | Site Map

window.onload() in IE and FF

 
LinkBack Thread Tools Search this Thread
  #1  
Old May 10th, 2006, 08:55 PM
McKirahan
Guest
 
Posts: n/a
Default window.onload() in IE and FF

Is it just me or did something change?

The following works under IE but not FF:

function window.onload() {
alert(0);
}

The following works under both IE and FF:

window.onload = function() {
alert(0);
}

I'm using Firefox 1.5.0.3.

I found nothing at: comp.lang.javascript FAQ

Thanks in advance.



  #2  
Old May 10th, 2006, 09:25 PM
Richard Cornford
Guest
 
Posts: n/a
Default Re: window.onload() in IE and FF

McKirahan wrote:[color=blue]
> Is it just me or did something change?
>
> The following works under IE but not FF:
>
> function window.onload() {
> alert(0);
> }[/color]

Yes, it is an ECMAScript syntax error. The syntax rules for function
declaration requires that the function name be an Identifier and -
window.onload - is a property accessor. IE is a little more tolerant but
it is still best to avoid IE specific syntax.
[color=blue]
> The following works under both IE and FF:
>
> window.onload = function() {
> alert(0);
> }
>
> I'm using Firefox 1.5.0.3.[/color]

No problem then.
[color=blue]
> I found nothing at: comp.lang.javascript FAQ[/color]

You couldn't have looked very hard then. There is advice on asking
sensible questions and references to the language specification.

Richard.


 

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.