Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Add Functions To Onload Event

DZone's Guide to

Add Functions To Onload Event

·
Free Resource
Original article


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

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}