JavaScript by Chris

Add multiple window.onload events

To add multiple window.onload events you can use

if (window.addEventListener) // W3C standard
{
  window.addEventListener('load', myFunction, false); // not 'onload'
} 
else if (window.attachEvent) // Microsoft
{
  window.attachEvent('onload', myFunction);
}

Comments

Leave a Comment

All fields are required. Your email address will not be published.