window.onload in external JS file

Hi
Is it okay to put the window.onload events in the external JS file along with the functions they are referring to?
e.g.
function populate (x,x){etc}
window.onload = function(){populate ('box_info.html', null);};

I have three functions and three window.onload calls, should I put them into the page head instead?  And if so, is there a syntax for doing all three at once rather than repeating the window.onload bit?

The functions aren't working in IE6 though they are in Firefox, but I'll post another question about that.  Thanks
Lady_MAsked:
Who is Participating?
 
Jai STech ArchCommented:
change your 3 onloads to
yes they go in the <head>
syntax
window.onload = function(){populate ('info.html', null);
rolloverButtons ();rolloverMenuL2 ();};
0
 
Jai STech ArchCommented:
there are no issues in having JUST the functions in a external JS file...they are just functions..you can call them in the onload even of the page <body onload ="javascript:somejsfunc();"
0
 
Lady_MAuthor Commented:
Hi

But, can I have the window.onload call in the external file as well??

If not, is there a shortened syntax for putting all three in the head of the page, I'd rather not put them in the body tag.

Thanks
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
Jai STech ArchCommented:
window.onload = function() { init(); doSomethingElse(); }
0
 
Jai STech ArchCommented:
you can write as many function calls as you need inside taht...
0
 
Lady_MAuthor Commented:
Sorryjaiganeshsrinivasa, I'm not getting what you mean.
I have these three onload events.  Each one is paired up with a different function at the moment, 2 in an external js file and one in the head.

Are you saying that they all need to go in the <head>?

And if so, could you please show me the syntax.

window.onload = function(){populate ('info.html', null);};
window.onload = function(){rolloverButtons ();};
window.onload = function(){rolloverMenuL2 ();};


Thank you.
0
 
Lady_MAuthor Commented:
Ah okay thankyou, got you.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.