Java Lab # 5

Introduction to Programming - CMPSC 204

 

Java Lab

In this project you will build a webpage using javascript.  The good news is that almost all of the the javascript source code will be provided.  See the following page for the sample source file.  The javascript is buried inside an HTML script webpage, meaning that there are two languages involved, one using the other. Often, webpages are built with higher level tools, but we as programmers need to know about the lower level code as well.

 

The provided source code must be typed in exactly, and tested to make sure it works.  It should be stored in a text file, and later renamed when completed as a .htm file. The .htm file will display a webpage that displays red, white or blue backgrounds when you click one of the buttons.  Your mission will be to add a button that will say "green" and switch the color to green when clicked.

 

Steps:

1. Open a new file with a plain text editor.  It is suggested that you use notepad, as notepad will not put in extra formatting elements and might not work properly.

 

2. Type into the text editor all of the material in the handout.  You must type it in exactly, or it may not work.

 

3. Save the file with a name such as "Redwhiteandblue". Change the Extension to .HTM.

 

4. Leave Notepade running and click on My Computer (or the windows explorer) and navigate to where you saved the file.

 

5. Now, from the My Computer file explorer, double click on the new .htm file.  It should come up and show you a screen with three color options.  Try them all and make sure they work.  If they don’t you have not typed it in correctly.  Go back to step 2 and fix it.

 

6. When it works, you are finished.  For 5 points extra credit, add a button Labeled Green that makes the page display a green background.

 

9. Print the webpage as a webpage, and print the notepad file with the java source in it.  Hand in both items.