Javascript Exercises

Final Assessment - Add these exercises to your Web site

Javascript Objective 1 - onload Event
Create a page that uses the body tag onload event to display an alert box.
The code for the alert box must be stored in an external .js file.

Javascript Objective 2 - Getting User input via Prompts
Create a page that displays a prompt asking for your name, stores it in a variable and writes it out to the screen in a large font.
Hint: window.prompt('Your Name','Enter your name');

Javascript Objective 3 - Writing to a new Window
Create a page with a button that opens a new and empty window and use document.write to add some text and a graphic to the new window.

Javascript Objective 4 - Displaying values in textboxes
Create a page with a textbox and button.
When the button is clicked the text in the textbox should display a suitable message.

Javascript Objective 5 - Operators
Create a page that has two text boxes.
Add a button, third text box and javascript that displays the sum of the numbers in the first two text boxes.
Now add buttons to do subtraction and multiplication.

Javascript Objective 6 - Home Page Creator
Create a form that accepts information from the user regarding
Their name and email, favourite background colour, text colour and a few lines of text on a subject of their choice.
Based on this information have javascript build them a home page.

Javascript Objective 7 - Functions and Parameters
Create a page with at least 4 buttons. Each button should display a colour name.
Pressing a button should change the background colour.
You must use one function that accepts different parameters.

Javascript Objective 8 - Rollovers
Create a page with a rollover image.
That is the image displayed changes as the mouse moves across the image.

Javascript Objective 9 - Frames and javascript
Create a page with at least three frames.
Use javascript to access text entered by the user in a textbox in one frame and transfer it into a textbox in another frame.

Javascript Objective 10 - Baking Cookies
Create a page that sets a cookie and another that retrieves its value.