JavaScript introduction and setup

Unit 2

JavaScript Samples

Look at the samples, and view their source documents.

The JavaScript file   sample-2-1-methods.js   contains:
var name = "George";
document.write(name);
document.write("<br />");
document.write( name.toUpperCase() );

The JavaScript file   sample-2-2-properties.js   contains:
document.bgColor = "navy";
document.fgColor = "white";
var name = "George";
document.write(name, "<br />", name.toUpperCase(), "<br />",
"The background color is ", document.bgColor);

The JavaScript file   sample-2-3-properties.js   contains:
document.write("<h2>Some Properties of the cat Image Object</h2>")
document.write("<code>id: ", window.document.cat.id, "</code><br />")
document.write("<code>width: ", window.document.cat.width, "</code><br />")
document.write("<code>height: ", window.document.cat.height, "</code><br />")

Everything that is written is copyrighted. Every image is copyrighted. To use copyrighted information you must purchase a right to use the material, have a right given to you, or be allowed to use it under "fair use" .
Some web sites give you the right to use their material, with some restrictions. Other sites do not grant you any right. Some other sites do not say they give you a right to use their material, but if you ask them they might give you a right.

Only the specific presentation of the information is copyrighted. If you read twenty different accounts about Martha Washington, and then write about Martha Washington, using the facts you have discovered, you own the copyright to your written material. The facts are not copyrighted, only the written presentation of the facts.
If you are writing about a fictional character, the character does not exist independent of the written copyrighted material, so there are no "facts" that you can use independently.

Fair use is permitted for use of a small amount of copyrighted material without the need to get permission. The amount of material must be small, such as one image or a few paragraphs. Your use of the material must be for your own use or for educational purposes. Your use must not harm the commercial interests of the copyright owner.

If you are doing commercial work, you must be very careful about copyrights. You should consult with your company's attorneys.

There have been changes in the copyright law in recent years. If you are not sure what to do about copyrighted material, ask an attorney who specializes in copyright law.

Lab 1 part B

In lab 1 part B you will build an index page for your lab pages. It will NOT contain any JavaScript; we will add JavaScript later.

Put your web page on the Internet

You have built your page; now follow the link to learn how to put it on the Internet, so everyone can see it.

Test your page

It is essential that your web pages be valid xhtml. You may get all kinds of problems with your JavaScript, if you do not have a valid xhtml web page. We will use the W3C validator, to verify that our web pages are valid.
Always validate your web pages before trying to get your JavaScript to work.

Use the link to the left to access the W3C validator. Validate your lab 1A and lab 1B pages now.

The link at the left will open the W3C validator in a new browser window.
To validate your page:

  • It is convenient to use two tabs, one for your page and one for the validator
  • Copy the address from the window that shows your page.
  • Paste the address of your page in the address field of the validator page.
  • Click on check
  • You will probably get a list of 38 errors; do not try to fix them all.
  • Try to find one error message, near the top of the list, that you think you might understand. Try to fix that one error.
  • Test it again.

Complete lab 1 part B

You have done all the work for parts A and B of lab 1.
Now, send note to instructor. In the note provide the following information:

  1. The subject of the email must be: JavaScript LAB 1A 1B
  2. It should say that you have completed Lab 1 parts A and B.
  3. It should give your voyager user account ID.
  4. It should provide a grade posting code word. It should be an English word of 7 characters or less. It is optional, but if you do not provide one, your grades are not shown.

If you are a Hotmail or Yahoo user, make sure the instructor's e-mail address is in your Safe List, in order to receive the reply. ( See Hotmail or Yahoo options for more information. )

Reading assignment

Reading assignments are in the text book, Java Script, A Beginner's Guide, Second Edition, by John Pollock; McGraw Hill / Osborne, ISBN 0-07-222790-7

Read Module 1. We will not use the projects in the book; we will have our own lab assignments. You may wish to do the Mastery Check at the end of each module; the answers are in the appendix.
The author of the book uses HTML; we will use XHTML, so be careful to upgrade to XHTML when you copy anything from the book.
You should use notepad, simpleText, vi, or some simple text editor; do not use a fancy editor which may add things to your web page that you do not want or understand.
The browser used in this class is the current version of Firefox. If you do not have Firefox, you can download it from www.mozilla.com/en-US/firefox/   As of 2007, current browsers support JavaScript version 1.6
Do not use html comments to hide JavaScript code from very old browsers. It fails with some newer browsers. The very old browsers are not used much any more. You can avoid these problems by using external JavaScript files, rather than putting the JavaScript in a style container in your html file.

Alternate reading assignments are in the text book, Java Script Concepts & Techniques Programming Interactive Web Sites, by Tina Spain McDuffie; Franklin, Beedle & Associates, ISBN 1-887902-45-7

You might want to look at Chapter 1 a little more.

Lecture notes

Do NOT read the lecture notes before hearing the lecture. If you do, you will find the lecture very boring. Read the lecture notes if you do not attend the lecture, or if you wish to review the material.