JDev

Code, javascriptFebruary 1, 2007 6:35 pm

Have a look at the function at http://www.ekcsoft.com/coding/js.php?page=js_format 

 
 
 
Code, javascript 4:10 pm

If you have existing functions on the onload event, you can add other functions without breaking the existing ones as follows:

var oldEvt = window.onload;
window.onload = function() { if (oldEvt) oldEvt(); doOtherStuffHere(); }

Lifted from one of the comments on http://simonwillison.net/2004/May/26/addLoadEvent/

The above method is useful if there are multiple external javascript files that may use the onload events. If you are sure there aren’t any external javascript files you could use a simpler version:

window.onload = function (firstFunction(); secondFunction();)