/ Published in: JavaScript
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { if (oldonload) { oldonload(); } func(); } } } addLoadEvent(nameOfSomeFunctionToRunOnPageLoad); addLoadEvent(function() { /* more code to run on page load */ });
URL: http://simonwillison.net/2004/May/26/addLoadEvent/