Introduction to Javascript
Placement of Javascript within a webpage
<HTML>
<HEAD>
<TITLE>Title</TITLE>
<SCRIPT LANGUAGE=JAVASCRIPT TYPE ="TEXT/JAVASCRIPT">
<!--
Javascript Statements and Functions
-->
<SCRIPT>
</HEAD>
<BODY>
</BODY>
</HTML>
Referencing a Javascript file within a webpage
<HTML>
<HEAD>
<TITLE>Title</TITLE>
<SCRIPT SRC="filename.js" LANGUAGE=JAVASCRIPT TYPE ="TEXT/JAVASCRIPT"> </SCRIPT>
</HEAD>
<BODY>
</BODY>
</HTML>
The use of a reference to a js file instead of including javascript in the document will allow you to call functions and pass values to them just as though the code were written in the webpage. Additionally the code can be used by many pages.
Triggering Javascript to run using a Hyperlink
<A HREF="javascript:Function name to run()" >Instruction to User. </A>
<A HREF="javascript:communicate()">Simple demonstration of prompt,alert and confirm. </A>
Inserting Comments in Javascript Code
Commenting code is important to any computer program. Additionally it is useful sometimes to comment sections of code when debugging a script in order to isolate an error.
// Single line comments of presented in this way with two forward slashes before the statement.
/*Multiline comments or sections of text are proceded by a foward slash and asterisk.
They are closed with an asterisk and forward slash
*/