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.

   1  
   2  window.onloadListeners=new Array();
   3  
   4  window.addOnLoadListener = function (listener) {
   5  	window.onloadListeners[window.onloadListeners.length]=listener;
   6  }
   7  
   8  window.onload=function(){
   9  	for(var i=0;i<window.onloadListeners.length;i++){
  10  		func = window.onloadListeners[i];
  11  		func.call();
  12  	}
  13  }
  14  
  15  //window.addOnLoadListener(function);
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS