Sample Tier I
JavaScript
Examples

 

Hello World

My first JavaScript page

Some background about variables

How Many Seconds in a Day?

Built-In Functions

Alerts

Alert Seconds Per Day

Prompts

Total Seconds in Days Inputted

Dates

Parsing the Date and Time

Navigator.properties

Obtaining information about the browser

A Simple Time of Day Message Script

Time of Day

Browser Router

Routing the User Based on Their Browser Type

Image Swapping & Rollovers

Find Out Your Personal Color

Color Your World

Switch to Another Image

Make My Day!

Switch When Multiple Images are Available

Choosing Image Swaps

A Rollover Example

Square the Circle
  A Rollover That Links Square the Circle Link

Preloading Images for Faster Performance

Rollover YinYang

Testing for Swapability

Is It A Swapable YinYang?

Manipulating Windows

Open Says A Me Opening a Window in JavaScript
Open onClick onClick Opening a Window
Open Resizable Only onClick Opening a Resizable Window
Open it Sized Only onClick Opening a Sized Window

Juggling Windows

More Window Manipulation

User Defined Functions

Finding your screen size

Get your screen size

Passing Inputs to Functions

Convert Fahrenheit to Celsius

Passing and Returning Information

Another Conversion

A More Complicated Function

Help on Window.prompt

Forms and Event Processing

A Registration Page Basic Form Elements
Load and Unload Events Alert( ) Messages Upon Entering and Exiting a Page
Firing Events on Controls Some Basic Form Events
Reading Controls Acquiring Inputs from Forms
Convert Fahrenheit to Celsius Using Textboxes for Both Input and Output
Resetting Defaults Writing Values to Forms from JavaScript Code
A Quick Jump Menu A Quick Jump Menu Using a Select/Drop Down Box
Another Quick Jump Menu Improving the Code for the Quick Jump Menu

Arrays and Loops

Summing the First N Natural Numbers Using a for Loop

Sum Using a for Loop

Summing the First N Natural Numbers Using a while Loop

Sum Using a while Loop

Built-In Arrays Associated with Images on a Web Page

Image Array
Strobing Colors in the Background Strobe Colors
Displaying an Array with X's and 0's Get the Picture

Working with Associative Arrays to Fill In Information

Quick Jump to Display the URL

Timing Events

Stop and Start

Incrementing a Value Once Every Second

Stop and Start Clean

Cleaning Up Some Aspects of the Duration Counter

Stop and Start Clock

Developing a Clock that Changes Each Second

Time Since and Remaining

Determining the Time Since the Semester Started and the Time Until it Ends

Timed Slide Show

A Timed Slide Show

Blue Lightning Animation

Speeding Up the Timing to Get an Animation

Frames

 

A First Frames Example

Organizing Page
 

Mouse Over to Change Contents of a Frame

MouseOver Changes
  Swapping Images in Different Frames OnClick Swaps
  Swapping Images in a Table More OnClick Swaps
  MouseOvers to Do Image Swaps MouseOver Swaps
 

Basics on Image Maps

 
Image Map Basics Monty Python Image Map  
Image Based Menu A Menu System Based on Image Maps  
 

Input Validation and Strings

 
Validating the Presence of Required Inputs Validate Registration Form
E-Mail Address Validation Validate E-Mail
Validation of Social Security Numbers Validate Social Security Numbers
Search for a String and Replace it With Something Search and Replace

Cookies

Setting Date and Time in a Cookie Setting and Reading Cookies
Setting a Name and Expiration Expiration and Access of Cookies