The old method of loading javascript code and functions on page load was the following:
window.onload = function ()
{
Javascript code goes here
}
This is all well and good and appears to do exactly what you want it to, however it's certainly not perfect.