Events << More Basics >> Functions
Before getting into the actual JavaScripting parts, here are a few other bits of information that will help you along the way.

alert Generates a pop-up ALERT box. This provides information and visitor clicks on OK to continue.
confirm Generates a pop-up CONFIRM box. This gives the visitor an OK or CANCEL choice.
document Refers to the current document or page displayed.
for Used to LOOP or repeat.
function This is kinda like a mini program. It is an area that carries out a small set of instructions to produce a certain outcome or result. These are usually found in the HEAD area of the code.
if ... else A comparison situation. IF something is true THEN do this ELSE do this.
location Specifies the current location of the page within the browser window or frame.
name Used to give a "name" to a specified object for reference.
prompt Generates a pop-up PROMPT box. This asks for visitor input.
src Stands for SOURCE. Tells the command to "look here" for the specified object.
status Refers to the STATUS bar along the bottom of the browser window.
var Stands for VARIABLE. This is where the algebra lessons come in handy. Variables are temporary storage units for a specified object or value.
window Refers to the current window in operation.
write Prompts the JavaScript to display some specified text.


There are different ways of creating comments within a JavaScript area. Comments are used to enter in a little description of what the code is going to do. These become most helpful when you are editing and want to quickly be able to understand what that part of the code is doing.

If the comment is just one single line, two forward slashes // are used.

If the comment is multiple lines, forward slash star /* is used to start the comment and star forward slash */ is used to end the comment.

The regular HTML comment <!-- // --> is still used to "hide" the actual javascript code from older browsers. The single line comment slashes are needed to hide the end of the ending comment tag. It's a bit complicated to explain, but it works.

<title> TEST </title>
<script type="text/javascript">

This is an example of a
multiple line comment.

// This is a single line comment.

Some JavaScript codes here.
// -->


Statement Endings

Each statement (or command) in a JavaScript block, should have a semi-colon ; to mark it's ending. This tells the browser "this command is done, start the next one.".

<script type="text/javascript">
document.write ( " This is my example text " );
document.write ( " This is my next example text " );
// -->

Adding HTML to JavaScript

JavaScript string variables also allow HTML coding. Placing regular HTML tags within the quotes of string variables, will allow you to control the formatting of your text.

<script type="text/javascript">
document.write ( "<b> This text is bold </b>" );
// -->
Events << More Basics >> Functions

Advertise in the banner along the top, Click here!

Valid XHTML 1.0 Transitional Valid CSS! Text Link Ads