Hello, please sign in or register
You are here: Home

Multiple onload events

Simply reads the events attached  to the window.onload event and creates a new function with the old onload event and the new one.

/**
 * Attach multiple window.onload events.
 */
function addLoadEvent(func)
{
	var oldonload = window.onload;

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

From http://www.webreference.com/programming/javascript/external/2.html

Comments

Title*
Comment

Prove you are not a robot

To prove you are not a robot, please type in the six character code you see in the picture below
Security confirmation codeI can't see this!
Contact
Name*
Email never shown*
Home Page

Author

Andrew Dodson
Since:Feb 2007

Comment | flag

Categories

Bookmark and Share