## Multiple onload (js)

I have a certain service on an ISP. Im having a few minor "hang" problems on page load.

Im assuming this is because both have "onload" calls, as do other modifications I'm using, and this "hang" is cause by the codes all loading at once?

I want to set the different mods to load in sequence instead by using a delay. E.G.

<BODY onLoad="javascript:alert('First Action');alert('Second Action');">

but im not sure how to go about it. If I listed the "onload" function of each modification I use, could somebody who knows what they are doing work out a code like above to specification for me and tell me where to put it?
(i presume css inline/ head tags equivalent?)

I.E

1 load "item one"
2 load "item two"
3 load "some other thing"

maybe something like this in an external js (but put where?)

CODEfunction start() {
function1();
function2();
function3();
}
window.onload = start;

Brainpower appreciated,
 PhysOrg.com science news on PhysOrg.com >> City-life changes blackbird personalities, study shows>> Origins of 'The Hoff' crab revealed (w/ Video)>> Older males make better fathers: Mature male beetles work harder, care less about female infidelity
 Recognitions: Gold Member Science Advisor Staff Emeritus Couldn't you just define a JavaScript function inside a script tag in the header, then call that function from your onLoad event? - Warren
 Recognitions: Science Advisor I'm confused as to what you want to do. The idea that i have is that all you want to do is load a number functions in sequence, but what is the difficulty in this? The code you posted, with the function start(), would accomplish this. Just copy the code from each of your onloads and place them inside functions defined in the html head, then call that function onload, like: Code:   But this is pretty much the same as you posted, so i can't see what is exactly challenging you at this point. Do you want a timer delay between the function calls? Do you want to avoid placing the onloads inside functions?

## Multiple onload (js)

 Quote by -Job- Do you want a timer delay between the function calls?
 Quote by Mattara I want to set the different mods to load in sequence instead by using a delay.
That is what I have in mind, but I'm not sure on how to accomplish it..
 Recognitions: Science Advisor Then use setTimeout to implement a delay between function calls. Nothing very complex, like: Code:  
 Just use toload_a('Script name'); to add functions in toload_e(). toload_e() will start on the page load. Code:  
 myfcr has it right (above). Each browser tends to load Javascript files and subroutines that are declared in the page header in a different (unpredictable) order, so you need to consolidate calls to each individual subroutine in one 'onload' subroutine, cause a delay at the top of the 'onload' subroutinet in order to let all the rest of them get loaded into memory, and then let the individual subroutines get called in the order you want. You'll need to test it in several different browsers and on slower machines to make sure it works in all cases.

 Similar discussions for: Multiple onload (js) Thread Forum Replies Mechanical Engineering 1 General Math 2 Introductory Physics Homework 2 Calculus & Beyond Homework 4 Introductory Physics Homework 6