JavaScript Lesson 1: Exercises

For each of these three exercises, you should create an HTML document. You should use Notepad to create the document, and save it as a file with the .html extension. You should use the examples from this lesson's notes as models -- some of these exercises only require small changes to the examples. Remember that your page should begin with the <HTML> tag and end with the </HTML> tag, and the body should be between <BODY> and </BODY> tags.

What to Turn In: For this first set of exercises, turn in exactly what you did for the HTML homework. That is, printout the HTML/JavaScript you wrote (using Notepad's print command), and printout the page itself as it displays in Netscape (of course, the page will look diffeent as you interact with it, but you only need print out one 'version' of each exercise).

Exercise 1.  Create a webpage containing four buttons which behave as follows when clicked:  the first turns the background purple; the second turns the background yellow; the third turns the background pink; and the fourth turns the background black.  The buttons should have the appropriate "labels" on them.

Exercise 2.  We worked with the window.status property a little bit.  This property is really intended to display status bar messages that are only to be shown briefly (like during a mouseOver event).  If you want the status bar to display a particular message even when the mouse isn't in an interesting location, you should use the window.defaultStatus property, which works almost exactly like the window.status property.  The differece is that once you set the defaultStatus property, that is the message that will be shown unless the status property causes it to change briefly.  So, create a webpage as follows:

Exercise 3.  We know how to change the background color of a document by using the bgColor property of the document object.  We can use other document properties to change other colors:  fgColor represents the color of the text; alinkColor represents the color of "unvisited" links (which are usually blue); and vlinkColor represents the color of "visited" links (which are usually sorta purple).  Create a webpage as follows:



[Back to Core 5GJ main page]