1. Home
  2. Computing & Technology
  3. JavaScript
photo of Stephen Chapman
Stephen's JavaScript Blog

By Stephen Chapman, About.com Guide to JavaScript since 2004

Combining onloads

Monday May 18, 2009
A common cause of scripts breaking when you add more than one to the same page is where each tries to assign something different to the onload event.

The process of combining scripts together on the one page where more than one is trying to assign an onload event is much simpler if you can just do a straight substitution for each of the assignments. Well by adding a small function to the code we can do just that.

Combining onloads
Comments
May 20, 2009 at 8:41 am
(1) Ted Murphy says:

How do you integrate this excellent idea with jQuery?

May 20, 2009 at 3:11 pm
(2) Stephen says:

JQuery has its own version of this built in so that you don’t need to do it yourself.

See http://docs.jquery.com/How_jQuery_Works#Launching_Code_on_Document_Ready

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>

Explore JavaScript
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. JavaScript

©2009 About.com, a part of The New York Times Company.

All rights reserved.