Archive

Archive for the ‘JavaScript’ Category

Make javascript functions load last

November 6, 2009 Leave a comment

Perhaps there’ll be a time when you need your javascript function to load last inside a page. Simply put the javascript code before the tag of your page. Done :)!

For example:

alert(“This alert is displayed when everything else has been loaded!”);

//calls an ajax command, non ajax-commands works too
new Ajax.Updater(‘droparea’, ‘my-cart.php’, { method:’post’, parameters: { action: ‘display’}});

p/s: Take note that javascript functions won’t be loaded unless you explicitly calls it first

for example:

//The script below won’t be called

function hoyoyo(){
alert(“This alert is displayed when everything else has been loaded!”);
}

So just add a caller to the function to make it work


hoyoyo(); //calls the function below
function hoyoyo(){
alert(“This alert is displayed when everything else has been loaded!”);
}

Categories: JavaScript, Programming Tags: