Appendix I
JavaScript Glossary
Objects
JavaScript is an object-oriented language, so at its heart are a pre-defined set of
objects which relate to the various components of an HTML page and their relation to each
other. To view or manipulate the state of an object requires the use of properties and
methods, which are also covered in this appendix. If an object is also used as a property
of another object, that relationship is listed following the definition. Related
properties, methods, and event handlers for each object are listed following the
definition.
anchors
A piece of text that can be the target of a hypertext link. This is a read-only object
which is set in HTML with <A> tags. To determine how many anchors are
included in a document, use the length property.
document.anchors.length
Unless the anchor name is an integer, the value of document.anchor[index] will
return null.
Property of document. See link OBJECT; see anchor METHOD.
button
An object that is a form element and must be defined within a <form> tag
and can be used to perform an action.
Property of form.
See OBJECTS reset and submit; see PROPERTIES name and value;
see click METHOD; see onClick EVENT HANDLER.
checkbox
A form element that the user sets to on or off by clicking and that must
be defined in a <form> tag. Using the checkbox object, you can see
if the box is checked and review the name and value.
Property of form. See radio OBJECT; see PROPERTIES checked, defaultChecked,
name, value; see click METHOD; see onClick EVENT
HANDLER.
Date
Replaces a normal date type. Although it does not have any properties, it is equipped
with a wide range of methods. In its current release, Date does not work with
dates prior to 1/1/70.
Methods for getting and setting time and date information are divided into four
classes: set, get, to, and parse/UTC.
Except for the date, all numerical representation of date components begin with zero.
This should not present a problem except with months, which are represented by zero
(January) through 11 (December).
The standard date syntax is "Thu, 11 Jan 1996 06:20:00 GMT". U.S.
time zone abbreviations are also understood; but for universal use, specify the time zone
offset. For example, "Thu, 11 Jan 1996 06:20:00 GMT+0530" is a place
five hours and 30 minutes west of the Greenwich meridian.
See METHODS getDate, getDay, getHours, getMinutes, getMonth,
getSeconds, getTime, getTimezoneOffset, getYear, parse,
setDate, setHours, setMinutes, setMonth, setSeconds,
setTime, setYear, toGMTString, toLocaleString, toString.
document
An object created by Navigator when a page is loaded, containing information on the
current document, such as title, background color, and forms. These properties are defined
within <body> tags. It also provides methods for displaying HTML text to
the user.
You can reference the anchors, forms, and links of a document by using the anchors,
forms, and links arrays of the document object. These arrays
contain an entry for each anchor, form, or link in a document.
Property of window. See frame OBJECT; see PROPERTIES alinkColor,
anchors, bgColor, cookie, fgColor, forms, lastModified,
linkColor, links, location, referrer, title, vlinkColor;
see METHODS clear, close, open, write, writeln;
see onLoad and onUnload event handlers.
elements
An array of form elements in source order, including buttons, checkboxes,
radio buttons, text and textarea objects. The elements can be referred to by their index:
formName.elements[index]
Elements can also be referenced by the element name. For example, a password element
called newPassword is the second form element on an HTML page. It's value is accessed in
three ways:
- formName.elements[1].value
- formName.elements["newPassword"].value
- formName.newPassword.value
Values can not be set or changed using the read-only elements array.
Property of form. See length PROPERTY.
form
A property of the document object. Each form in a document is a separate and
distinct object that can be referenced using the form object. The form
object is an array created as forms are defined through HTML tags. If the first form
in a document is named orderForm, then it could be referenced as document.orderForm
or document.forms[0].
Property of document. See hidden OBJECT; see PROPERTIES action, elements,
encoding, forms, method, name, target; see submit
METHOD; see onSubmit EVENT HANDLER.
frame
A window that contains HTML sub-documents that are independently scrollable. Frames
can point to different URLs and be targeted by other frames-all in the same window. Each frame
is a window object defined using the <frameset> tag to define the
layout that makes up the page. The page is defined from a parent HTML document. All
sub-documents are children of the parent.
If a frame contains definitions for SRC and NAME attributes,
then the frame can be identified from a sibling by using the parent
object as parent.frameName or parent.frames[index].
Property of window. See document and window OBJECTS; see
PROPERTIES defaultStatus, frames, parent, self, status,
top, window; see METHODS setTimeout and clearTimeout.
hidden
A text object suppressed from appearing on an HTML form. Hidden objects can be
used in addition to cookies to pass name/value pairs for client/server
communication.
Property of form. See PROPERTIES cookie, defaultValue, name,
value.
history
This object is derived from the Go menu and contains URL link information for
previously visited pages.
Property of document. See location OBJECT; see length
PROPERTY; see METHODS back, forward, go.
link
A location object. In addition to providing information about existing
hypertext links, the link object can also be used to define new links.
Property of document. See anchor OBJECT; see PROPERTIES hash,
host, hostname, href, length, pathname, port,
protocol, search, target; see link METHOD; see onClick
and onMouseOver EVENT HANDLERS.
location
Contains complete URL information for the current document, while each property of location
contains a different portion of the URL.
Property of document. See history OBJECT; see PROPERTIES hash,
host, hostname, href, location, pathname, port,
protocol, search, target.
Math
Includes properties for mathematical constants and methods for functions. For example,
to access the value of pi in an equation, use:
Math.PI
Standard trigonometric, logarithmic, and exponential functions are also included. All
arguments in trigonometric functions use radians.
See PROPERTIES E, LN10, LN2, PI, SQRT1_2, SQRT2;
see METHODS abs, acos, asin, atan, ceil, cos,
exp, floor, log, max, min, pow, random,
round, sin, sqrt, tan.
navigator
Contains information on the current version of Navigator used by the client.
See OBJECTS link and anchors; see PROPERTIES appName, appCodeName,
appVersion, userAgent.
password
Created by HTML password text fields, and are masked when entered by the user. It must
be defined with an HTML <form> tag.
Property of form. See text OBJECT; see PROPERTIES defaultValue,
name, value; see METHODS focus, blur, select.
radio
Objects created within HTML <form> tags and represent radio buttons. A
set of radio buttons enables the user to select one item from a list. When it is created,
it takes the form of document.formName.radioName[index], where the index is a
number representing each button beginning with zero.
Property of form. See OBJECTS checkbox, select; see
PROPERTIES checked, defaultChecked, index, length, name,
value; see click METHOD; see onClick EVENT HANDLER.
reset
Correlates with an HTML reset button, which resets all form objects to their
default values. A reset object must be created within a <form> tag.
Property of form. See OBJECTS button and submit; see
PROPERTIES name and value; see click METHOD; see onClick
EVENT HANDLER.
select
A selection list or scrolling list on an HTML form. A selection list enables the user
choose one item from a list, while a scrolling list enables the choice of one or more
items from a list.
Property of form. See radio OBJECT; see PROPERTIES length, name,
options, selectedIndex; see METHODS blur and focus;
see EVENT HANDLERS onBlur, onChange, onFocus.
For the options PROPERTY of select, see defaultSelected, index,
selected, text, value.
string
A series of characters defined by double or single quotes. For example:
myDog = "Brittany Spaniel"
returns a string object called myDog with the value "Brittany
Spaniel". Quotation marks are not a part of the string's value-they are only
used to delimit the string. The object's value is manipulated using methods that return a
variation on the string, for example myDog.toUpperCase() returns "BRITTANY
SPANIEL". It also includes methods that return HTML versions of the string, such
as bold and italics.
See text and textarea OBJECTS; see length PROPERTY; see
METHODS anchor, big, blink, bold, charAt, fixed,
fontcolor, fontsize, indexOf, italics, lastIndexOf,
link, small, strike, sub, substring, sup,
toLowerCase, toUpperCase.
submit
Causes the form to be submitted to the program specified by the action
property. It is created within an HTML <form> tag. It always loads a new
page, which may be the same as the current page if an action isn't specified.
Property of form. See OBJECTS button and reset; see
PROPERTIES name and value; see METHOD click; see EVENT HANDLER onClick.
text
A one-line input field on an HTML form that accepts characters or numbers. Text
objects can be updated by assigning new contents to its value.
Property of form. See OBJECTS password, string, textarea;
see PROPERTIES defaultValue, name, value; see METHODS focus,
blur, select; see EVENT HANDLERS onBlur, onChange, onFocus,
onSelect.
textarea
Similar to a text object, with the addition of multiple lines. A textarea
object can also be updated by assigning new contents to its value.
Property of form. See OBJECTS password, string, text;
see PROPERTIES defaultValue, name, value; see METHODS focus,
blur, select; see EVENT HANDLERS onBlur, onChange, onFocus,
onSelect.
window
Created by Navigator when a page is loaded containing properties that apply to the
whole window. It is the top-level object for each document, location,
and history object. Because its existence is assumed, you do not have to
reference the name of the window when referring to its objects, properties, or methods.
For example, the following two lines have the same result (printing a message to the
status line):
- status("Go away from here.")
- window.status("Go away from here.")
A new window is created using the open method:
aNewWindow =
window.open("URL","Window_Name",["windowFeatures"])
The variable name is used to refer to the window's properties and methods. The window
name is used in the target argument of a form or anchor tag.
See OBJECTS document and frame; see PROPERTIES defaultStatus,
frames, parent, self, status, top, window;
see METHODS alert, close, confirm, open, prompt,
setTimeout, clearTimeout; see EVENT HANDLERS onLoad and onUnload.
|