Never been to DZone Snippets before?

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

About this user

Bryan Gidge http://www.gidge.com

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

Javascript Window OnLoad Listener

This script gives the ability to run javascript functions after the page has loaded. I definitely can't take credit for this, as it's one I found, but I use it constantly.

window.onloadListeners=new Array();

window.addOnLoadListener = function (listener) {
	window.onloadListeners[window.onloadListeners.length]=listener;
}

window.onload=function(){
	for(var i=0;i<window.onloadListeners.length;i++){
		func = window.onloadListeners[i];
		func.call();
	}
}

//window.addOnLoadListener(function);
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS