CMSC 104, Spring 2008
Homework 3
Your First JavaScript Program
Out:Thursday, March 27
Due:Tuesday, April 1, before 11:59 p.m.
Note: No late projects will be accepted.
The Objective
- To learn to create and run JavaScript programs
- To become familiar with syntax error messages generated by the
JavaScript error console.
The Task
- Before you begin working on the assignment, you must set up
your account so that no one else can see your Web page while you
are working on it. You will only be able to access your page
by typing in a username and password. The only people who will
be able to access your page are you, me and the graders for the
class. You *must* do this step before you begin working on your
page. Note that when you type in your password for the script
nothing will show up on the screen, just type it and hit enter.
Type the following command at the linux prompt:
linux2[12]% /afs/umbc.edu/users/d/b/dblock/pub/setup104
You should see something similar to the following:
linux2[12]% /afs/umbc.edu/users/d/b/dblock/pub/setup104
Creating new directory: /afs/umbc.edu/users/c/m/cmsc/pub/access
Using exising directory: /afs/umbc.edu/users/c/m/cmsc/pub/www
Using exising directory: /afs/umbc.edu/users/c/m/cmsc/pub/www/cs104
Using exising directory: /afs/umbc.edu/users/c/m/cmsc/pub/www/cs104/hw3
Using exising directory: /afs/umbc.edu/users/c/m/cmsc/pub/www/cs104/proj1
Using exising directory: /afs/umbc.edu/users/c/m/cmsc/pub/www/cs104/proj2
Using exising directory: /afs/umbc.edu/users/c/m/cmsc/pub/www/cs104/proj3
Using exising directory: /afs/umbc.edu/users/c/m/cmsc/pub/www/cs104/proj4
*********************************************************************
* Please enter a password other than your myUMBC/GL password below. *
* This will be the password you need to access your pages online. *
*********************************************************************
Creating new password file
New password:
Re-type new password:
Adding password for user cmsc
linux2[13]%
- After you run the setup script, you will be asked for a password when you
eventually look at your Web page for the assignment in the Web browser.
- For the first part of the assignment, you must complete the
program attached to this sheet (to be distributed in class) by
filling in the blanks where pieces of code are missing.
- After filling in the blanks, you are ready to move on to the second
part of the assignment.
- Change into your hw3 directory. (
cd ../pub/www/cs104/hw3
).
- Use xemacs (
xemacs hw3.html
) to type
in the JavaScript program. You should type the program in INCREMENTALLY!!
Type it in EXACTLY AS SHOWN, including all spacing and indentation. Some exceptions:
- Insert YOUR name as the author.
- Insert YOUR username.
- Insert a heading of your choice on the page where it says "Heading for Your Page."
- You may add a <style>...</style> section to the head section of the
page if you'd like to change the colors, fonts, etc.
-
The program must be called
hw3.html
Using the JavaScript Error Console
- The JavaScript error console will help you find errors in your program. To run the error
console in Firefox, go to Tools->Error Console. It will bring up a separate window
containing the error console. You should use the Clear button to clear the error
console and then refresh your web page. If there are any problems with your JavaScript
code, they should show up in the error console.
Sample Run
- The URL for your page will be http://userpages.umbc.edu/~username/cs104/hw3/hw3.html, where
username is your GL/myUMBC username. You should refresh the page several times and run the
program with different sets of values. You can assume that the user will only enter numbers as input.
Here are some sample screenshots of the program:
User entering first number
User entering second number
Final results page