Category Archive: Javascript

Subcategories: No categories

Multiple Onload Functions

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];

And then where you need an onload event callback do this:

onload_functions.push(function() {alert('The page loaded...'););


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...');});.