Link to home
Start Free TrialLog in
Avatar of Lady_M
Lady_MFlag for United Kingdom of Great Britain and Northern Ireland

asked on

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
Avatar of Jai S
Jai S
Flag of India image

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();"
Avatar of Lady_M

ASKER

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
window.onload = function() { init(); doSomethingElse(); }
you can write as many function calls as you need inside taht...
Avatar of Lady_M

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of Jai S
Jai S
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Lady_M

ASKER

Ah okay thankyou, got you.