[thelist] [JS] window.onload is a liar...

Tom Dell'Aringa pixelmech at yahoo.com
Tue Mar 16 06:42:24 CST 2004

--- liorean <liorean at f2o.org> wrote:
> window.onload should be a function - it will trigger when the
> document has loaded. You, however, assign it the return value of a 
> function.

When you say it should be a function - do you mean to say
window.onload *itself* is a function and that it triggers - or that a
function should be *assigned* to it?

Second question: So doing it my original way is not assigning a
function but assigning it a return value?

> window.onload=BuildSelect;
> will assign the function itself to the onload handler. However, you
> are losing the argument if you do thus. How to fix that?
> window.onload=function(){
>      BuildSelect(arr);
> }

Riiight thats it! Good heavens my memory is shot. Could you explain
the difference? I'm not quite grasping why my first version fails and
this works. It seems both ways you assign a function to the event
handler. I know they are different, but I can't quite wrap my fat
head around it - and I am going to have to explain it!

Thanks as ever David!


http://www.Pixelmech.com/ - read my latest blog posting!
http://www.DMXzone.com/ - JavaScript Author
http://SparklesParties.com - Princess parties for little girls!
http://www.thywordistruth.net/ - Eternal Life

"Well, my name's Dewey Oxburger. My friends call me Ox. I dont know if you've noticed, but I got a slight weight problem."

More information about the thelist mailing list