The window has an "onload" event which you can listen to with:
window.addEventListener("load",myOnLoadFunction)
Though for more cross-browser compatibility, you may want a function like the below, as older IE versions use .attachEvent instead of .addEventListener
function addEvent(obj,evnt,func)
{
if(typeof func !== 'function')
{
return false;
}
if(typeof obj.addEventListener == 'function')
{
return obj.addEventListener(evnt.replace(/^on/,''), func, false);
}
else if(typeof obj.attachEvent == 'function' || typeof obj.attachEvent == 'object')
{
return obj.attachEvent(evnt,func);
}
}
Then call:
addEvent(window,'onload',myOnLoadFunction);