![]() |
![]() |
The purpose of this page is to demonstrate some of the features of HMTL that you should be using in your work.
JavaScript is the scripting language of the Internet. It is the most popular scripting language on the World Wide Web and is used in hundreds of thousands of Web pages. JavaScript is the "glue" which binds together html elements, JavaScript scripts, Java applets, and plug-ins and allows these objects to communicate and interoperate.
Javascript is a scripting language originally developed by Netscape (there is now a version developed by Microsoft called Jscript)
It allows you to add interactivity to your web pages
Javascript scripts are embedded directly into web pages
They can be in the <head> or in the <body> of the page depending on what you want the script to do
Javascript involves the scripts and the objects manipulated by the scripts
Both will be explained below.
Some of the ways that Javascript can be used on a page:
These are parts of the web browser that can be manipulated as whole entities
Another way to think of an object is as a black box which contains a chunk of information or data
A <window> is an example of a javascript object. However, it has qualities which are also objects (with their own qualities). Here is an example of objects and their relationships:
This is a hierarchy of objects that illustrates their relationships (this illustration doesn't include them all)
This is a version of a document object model
Understanding these relationships will be useful when you are creating your own javascript scriptsWhen you create scripts, you want to arrange the proper objects in the proper order
Properties: Objects have properties, or qualities that define them
Think of properties as the information in the object that can be read, changes, or otherwise directly accessed
Properties typically define the visual appearance of the object
They also define the current settings of the object
Normally, we will assign properties with the attributes placed in the HTML markup
Here's an example:
A web page is an object which is called a document
One property of a document is its background color
The property can be expressed on dot.syntax as:
document.bgcolor
If you want to change this color, you specify a value for this property:
document.bgcolor="cyan"
A property can be used with several different objects
Also, a property of an object can be an objectwith its own properties
For example, a form is a property of a document, but is also an object with such properties as radio buttons and check boxes
Other properties of documents include:
anchor applets bgcolor cookie
image links title URL
Methods: are the functions that objects can perform in scripts
Methods are used to indirectly access the information or data contained in objects
Some objects have many methods, others have none
Anchor has no methods
Date, another object has 22 methods including:
getDate getHours getMinutes getTime setDate setMonth setTimes setYear
dot.syntax: Javascript uses dot syntax to put these components together
The combined components can describe objects or processes
For example:
document.write(Here's an example of a small script)
Events are the functions that can be performed on a web page
Javascript contains a set of 12 event handlers which can react to these functions
Event handlers are small pieces of code which run when certain things happen on the web page
They are triggers that respond to user actions
What happens depends on the actions that are defined for the specific event handler
The event handlers are:
Event handler User action Event handler User action onAbort Stopped loading the page onBlur Left the object onChange Changed the object onClick Clicked on the object onError Error while script is executing onFocus Made object active onLoad Object has loaded onMouseover Cursor passed over the object onMouseout Cursor moved off the object onSelect Selected the object onSubmit Submitted a form onUnload Left the page
Event handlers are important building blocks of Javascript programs
Here are some other basic components you need to create Javascript scripts
| Demo Page Navigation: |
DemoPage contents | About HTML | UNIX help | HTML tags | Lists | Links | Images |
| Imagemapping | Tables | Forms | Frames | Javascript | CSS (style sheets) | XML |
| Page by Howard Rosenbaum | |
| Find me at hrosenba@indiana.edu | http://www.slis.indiana.edu/hrosenba/www/Demo/Demo23.html |