JavaScript: Overloading Window onload

Quick post on a very common methodology I've been using to chain events to the window.onload event in pure JavaScript:

if (window.onload == null) {
window.onload = loadAutoSubmitScript;
} else {
var ol = window.onload;
window.onload = function() { ol(); loadProc(); }

function loadProc() { alert("The window is loaded"); }

This should work for pretty much every page you use.

Over and Out

No comments: