Welcome
................................

Schedule
................................

Calendar
................................

Guidelines
................................

Journaling
................................

Our Websites
...............................

Contact Info
...............................

Resources
...............................

Links
...............................


 

JavaScript

JavaScript is a client-side scripting language that adds interactivity and functionality to webpages.

JavaScript is an Interpreted Scripting Language
Interpreted Scripting languages run in a particular environment (such as a web browser) and do not need to be compiled. The JavaScript interpreter is built into the browser and executes the script step-by-step.

Syntax
The rules by which you must script the code to be valid and can be parsed by the browser.
Scripts All JavaScript should be placed within a <script> tag. The <script> tag tells the browser to run the code through the JavaScript interpreter. Any JavaScript that is outside of a script tag will be rendered as plain text.

Head Scripts
Any script you want to call before the body (<body>) loads should be put in the <head>. Any functions you want to be available from within the <body> should also be put in the <head>

Body Scripts
Any script you want to load when the page loads should be written in the <body>. The body also contains references to the functions that call the function to be executed at the proper time.

Object-Based
JavaScript uses objects (structured code) to allow easy organization and manipulation of web pages. Basically objects are collections representing nouns (people, places and things). For example, the document (a predefined object in JavaScript) object represents the <html> code used to build a web page.

Variables and Properties
A container that stores a piece of data. Properties are variables that belong to an object. For example, the location property of the document object stores the url of the web page. All variables are properties of some object. If you do not specify an object for a variable it automatically belongs to the predefined window object.

Functions and Methods
A function contains lines of code that are not executed immediately. When you just place lines of code within a <script> tag, the lines are executed immediately as the page is processed by the browser. Declaring a function allows you to define code that can be executed later or triggered by an event. Methods are functions that belong to an object. For example the write method is a function that belongs to the document object.

You call a function by using a function statement. The basic syntax for a function statement is:
FunctionName();

Operators
Operators are symbols that perform specific actions. The “+” operator performs addition of two numbers. The “-“ operator performs the subtraction of two numbers. There are many operators to perform arithmetic and comparison actions.

the Dot Operator
The dot operator is how you “get into” an object. For example to get the location property of the document object you would use the syntax document.location. Likewise to call the write method of the document object you would use document.write().

Comments
There are two types of comments: HTML comments and JavaScript comments. Comments prevent lines of code from being interpreted by the browser.

The syntax for an HTML comment is:
<!-- COMMENTED CODE HERE -->

The syntax for a JavaScript comment is:
// COMMENTED CODE
or
/* COMMENTED CODE */

The difference between the two JavaScript comments is the “//” comments out all of the code to the end of the same line, while the “/* */” comments out all of the code between the comments even if the code spans many lines.

It is common to wrap your JavaScript within an HTML comment so older browsers that can not handle JavaScript will not throw errors. To comment out your JavaScript you have to use a combination of HTML and JavaScript comments.

Here is the syntax:
<script>
<!--
document.write( document.location );
//-->
</script>

Normal usage of comments is recommended because you can describe what you are doing with your code so you and others can quickly discover what is happening in the code.

Here are some examples of basic JavaScript that you can use.

Additional resources
Webmonkey's JavaScript Code Library
  
  
  
  
  

welcome | schedule | contact | resources | links

Site designed and developed by
Daniel O'Connell

Any questions or problems: