Home > JavaScript, Programming > Make javascript functions load last

Make javascript functions load last

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!”);
}

Advertisements
Categories: JavaScript, Programming Tags:
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: