Return to Snippet

Revision: 43847
at April 1, 2011 02:56 by garretjames


Initial Code
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

addLoadEvent(nameOfSomeFunctionToRunOnPageLoad);
addLoadEvent(function() {
  /* more code to run on page load */
});

Initial URL
http://www.webreference.com/programming/javascript/onloads/

Initial Description
Not my Code, credit is in the URL.

Initial Title
OverRide or Append to JavaScript onload event

Initial Tags

                                

Initial Language
JavaScript