DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Add Functions To Onload Event

10.07.2005
| 2813 views |
  • submit to reddit
        <a href="http://www.eslomas.com/index.php/archives/2005/10/07/anadir-facilmente-funciones-al-evento-onload/">Original article</a>

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