Web Hosting Directory | Web Hosting Resources | Webmaster Resources | Domain Tools | Search Engine Marketing | Forums
  Signup
Today: 1,222   Yesterday: 1,015   Max: 1,872   Total: 464,275   Current Users : 33 (Member 0) 
DOMAIN TOOLS

WEBMASTER TOOLS

RELATED ARTICLES

SUBMIT AN ARTICLE

Write for us and get publicity, link to your website, and best of all get paid. Please visit our writers page for details.


LINK TO US

Link to us and earn points for each visitor you bring to us. Please visit our link partner page for details.

 

Running Two (or more) Commands With onLoad

A common question we get is how to run two different commands with <BODY onLoad="...">. It's pretty simple: just put both of them in the onLoad attribute with a semicolon between them. It also might be simpler to put the commands in a separate function and call the function in onLoad.

For example, suppose you want to run this command when the document is loaded:

alert('Hello There!')

and you also want to run this command:

alert('Howdy!')

You can do this by putting them both in the onLoad attribute separated by a semicolon:

<BODY onLoad="alert('Hello There!'); alert('Howdy!')">

If you want to run more than two commands, just put semicolons in between all the commands. However, this tends to get messy, so it's usually a good idea to put the commands in a single function and call the function from onLoad. So, for example, you could create a function called init() by putting this script in the <HEAD> section of your page:

<SCRIPT TYPE="text/javascript">
function init()
{
alert('Hello There!');
alert('Howdy!');
}
//-->
</SCRIPT>

Then you can call init() with this onLoad attribute:

<BODY onLoad="init()">



Copyright 1997-2002 Idocs, Inc. Written by Miko Sullivan.

 
 
 
What is your major source of website traffic?
 
 
 
 
 
 

ADVERTISEMENT

 
Cheap Web HostingBudget Web HostingEcommerce Web Hosting
Link to UsLink ExchangeAdvertisePrivacy PolicyTerms Of ServiceAbout UsContact UsSitemap
Copyright © 2006 - 2008 Broadband Media, Inc. All rights reserved.