/ Published in: JavaScript
Description: Execute different functions when the page loads in a better way than default onload JS event. Include it in the end of the JS document.
Arguments: Name of the function that you want to execute when the page loads.
Author: Simon Willison
Arguments: Name of the function that you want to execute when the page loads.
Author: Simon Willison
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() { oldonload(); func(); } } }
URL: http://simonwillison.net/2004/May/26/addLoadEvent/