Return to Snippet

Revision: 45156
at April 26, 2011 11:24 by derdesign


Initial Code
/* Run code inside a new namespace. This will allow the use of 
 * the same variable 'previous_onload', across multiple namespaces.
 *
 * Use the exact same code multiple times, and your functions
 * will be executed in the order in which they were stacked. */

(function() {

	// Backup previous onload method.

	var previous_onload = window.onload;
	
	window.onload = function() {

		try { previous_onload(); } catch(e) { } // Execute. Ignore if error.

		// Your code goes here
		
		console.log("Running Code...");

	}

})();

Initial URL
http://paste.pocoo.org/show/378207/

Initial Description
Window.onload chaining using Namespaces.

Initial Title
JavaScript window.onload chaining

Initial Tags
javascript

Initial Language
JavaScript