Lady_M
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
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
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(); "
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
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...
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.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ah okay thankyou, got you.