<BODY ...><BODY onLoad="..."><BODY onLoad="..."> | <BODY onUnload="..."> |
>>> |
onLoad
A common question we get is how to run two different commands with
<BODY onLoad="...">onLoadonLoad
For example, suppose you want to run this command when the document is loaded:
alert('Hello there!')
and youalso want to run this command:
alert('Howdy!')
You can do this by putting them both in the onLoad
<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
onLoadinit() by putting this script in the
<HEAD>
<SCRIPT TYPE="text/javascript">
function init()
{
alert('Hello there!');
alert('Howdy!');
}
//-->
</SCRIPT>
Then you can call init() with this
onLoad
<BODY onLoad="init()">