Using JavaScript

There are three approaches to using JavaScript in your Web pages -

1. Write the code as part of the page HTML between <SCRIPT>, </SCRIPT> tags.
eg.
....
<BODY>
.....

<SCRIPT>
.....
document.write("Hello World")
.....
.....

</SCRIPT>
.....
</BODY>
2. Define a function and then "call" it later in the HTML.
eg
function Multiply(x,y)
{
   var result = x * y
   return result
}

This could be 'called' later in the page using:
var answer = Multiply (3,7)
document.write("The answer is:", answer);

3. Insert a JavaScript command as part of an 'anchor' statement (ie as part of  <A HREF= ........>........</A>)
eg
<BODY>
.....

<A HREF = "#" onMouseOver = "window.alert( )"> This is a MouseOver position </A>
.....
</BODY>

NOTE: Approach 1 can be simply inserted into your HTML page at any point. Approach 2 requires you to 'declare' the function between  the <HEAD>, </HEAD> markers at the top of the page. You will also need to declare that you are using JavaScript commands with <SCRIPT language="JAVASCRIPT"> and later turn it off with </SCRIPT>. The following screens give examples of each approach.

<- Back - MenuNext ->