Here's a quick way not so good way (see update) of getting multiple javascript functions to be called when the page has finished loading.
Add this to the pages Head section:
<script type="text/javascript" charset="utf-8">
var onload_functions = new Array();
window.onload = function() {
for (i in onload_functions) {
var onload_function = onload_functions[i];
onload_function();
}
}
</script>
And then where you need an onload event callback do this:
onload_functions.push(function() {alert('The page loaded...'););
Update:
As pointed out by phihag, this solution isn't great, instead try using phihag's code or use jquery and just $(document).ready(function{} {alert('The page loaded...');});.
Unnecessarily complex. Just use
function addonload(olhandler) {
if (window.addEventListener) { // DOM
window.addEventListener("load", olhandler, false);
} else if (window.attachEvent) { // IE
window.attachEvent("onload", olhandler);
} else {
var olh = window.onload;
window.onload = function() {
if (typeof oldh == "function") {
oldh();
}
olhandler();
};
}
}
oh, and please allow the code in this comment field
Good point, events would be easier.
Fixed your first comment, code needs to be indented by 4 spaces in markdown.