• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1233
  • Last Modified:

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
0
Lady_M
Asked:
Lady_M
  • 4
  • 3
1 Solution
 
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
 
Jai STech ArchCommented:
window.onload = function() { init(); doSomethingElse(); }
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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
 
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
 
Lady_MAuthor Commented:
Ah okay thankyou, got you.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now