Return to Snippet

Revision: 4228
at November 9, 2007 10:41 by Butscharoni


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://simonwillison.net/2004/May/26/addLoadEvent/

Initial Description
Simon Willsons page load fix.

Initial Title
Execute after page load

Initial Tags

                                

Initial Language
JavaScript