Using Multiple JavaScript OnLoad Events
The following example shows out to use the onload event using a function. Normally, you cannot just do multiple onload events, because once the first is finished, the second onload event will fire and replace the first and so on. This function addLoadEvent allows you to have multiple onload events.
function addLoadEvent(func)
{
var oldonload = window.onload;
if(typeof window.onload != 'function')
{
window.onload = func;
}
else
{
window.onload = function(){
if(oldonload)
{
oldonload();
}
func();
}
}
}
function myfunction()
{
alert("the page has loaded");
}
addLoadEvent(function(){
myfunction();
});
addLoadEvent(myfunction());
http://www.webreference.com/programming/javascript/onloads/ »
[Click to add or edit comments])
Please prepend comments below including a date