JavaScript Lessons
D. Baggs, Annapolis, MD - Last updated on February 28,2000
Here are my
assignments
Exercises-examples
- Week One: Introduction
- JavaScript is a client-side language- the code resides within the Web page. It is a hybrid between a programming language and a markup language - the former because it provides a set of instructions, the latter because it is less strict.
Self-Review Questions
- JavaScript is a compact, object-based scripting language which allows the viewer to interact.
- JavaScript was invented by Netscape with Sun Microsystems
- JavaScript is different from Java as follows:
- Interpreted rather than compiled
- Object-based, but no inheritance
- Code integrated with and embedded in HTML
- Variable data types not declared
- Dynamic (vs. Static) binding - Object references checked at run-time
- JavaScript may lead to ECMAScript (European Community Manufacturer's Association) and it can write a text-based cookie.
- It does not access and control a user's computer.
Week Two:
First Script:
- Script tag is usually embedded in the HEAD tags and usually is seen as <script language="JavaScript">
- The HTML comment tags are used to hide the JavaScript from non-JS capable browsers.
- Closing comment tag includes two forward slashes and HTML.
Rules
- Capitalization matters
- Opening symbols require matching closing symbols.
- Use Comments
- Scripts are made up of statements with the following structure:
- Statement starts on its own line.
- The first item is a command
- Next is some information, like a value
- Last is a trailing semi-colon.
- Groups of statements make command blocks:
- Starts on it's own line with an open brace-{
- Next -one or more individual statements ending with semi-colon
Good to indent.
- Last is closing brace -}
Week Three:
Adding Interactivity:
Objects:
    Things which have unique names. Similar to a noun.
Properties:
    Can modify objects and are like sub-objects.
Methods:
    What objects do Similar to a verb.
Dot Syntax:
    Used to put together objects, properties, and methods.
| Event Handlers |
onAbort
onBlur
onChange
onClick
onError
onFocus
|
onLoad
onMouseover
onMouseout
onSelect
onSubmit
onUnload
|
Values and Variables
- Value
- Piece of information - numbers and strings.
- Value Types
- Consist of number, string, boolean, null, object, and function.
- Operators
- Symbols that work with variables. Examples are math functions.
Review Questions:
- Objects are things
- Properties are characteristics which can modify objects
- Methods are things objects can do - actions
- Dot syntax puts together objects, prop's, meth's
- Event handlers are actions visitors perform - commands
- Values are information - numbers/strings
- Variables contain values
- Operators are symbols that work w/variables
Back to top
Week 4:   Exercises
Week 5: Review:
Examples in Assignments
Alerts, prompts and confirms are three methods of the window object.
They create predefined, popup types of dialogue objects within a window object.
Clicking OK in an alert box makes the box disappear.
A prompt box has a space for writing.
A confirm box has a question.
A function is a set of Java statements that perform a task.
It is made up of the word function followed by the name, parentheses,
and an open brace bracket, statements, and a closing brace bracket.
Week 6: Review:
Example in Assignments
A window opened with HTML will give the same size as the main window. JavaScript gives more control over size and properties.
type=full window opens new window on entire desktop with only the title bar.
Popups can be invoked using graphic link by using img src tag
Week 7: Review:
Without a check for recognition of images for navigation, a user wouldn't be able to go anywhere.
The mouseover event calls the image defined in over1, etc. list and creates a message in the status bar.
Onmouseout calls the image defined in off1, etc. list.
Preloading images helps because you have twice what you see at first.
Example Drop-Down Menu in Assignments
Exercises - Example of Mouseover
Back to Web Design
Back to top