tag is deprecated in HTML 4.0 because style sheets can provide the same capability. Document Object Model (DOM)
The set of objects that JavaScript can use to refer
to the browser window and portions of the HTML document. The W3C (World Wide Web Consortium) DOM is a standardized version supported by the latest browsers, and allows access to every object within a web page. Dynamic HTML (DHTML)
The combination of HTML, JavaScript, CSS, and the
DOM, which allows dynamic web pages to be created. DHTML is not a W3C standard or a version of HTML. element
A single member of an array, referred to with an index. In the DOM, an
element is a single node defined by an HTML tag. event
A condition, often the result of a user’s action, that can be detected by a
script. event handler
A JavaScript statement or function that will be executed when an
event occurs. expression
A combination of variables, constants, and operators that can be eval-
uated to a single value. feature sensing
A scripting technique that detects whether a feature, such as a
DOM method, is supported before using it to avoid browser incompatibilities. function
A group of JavaScript statements that can be referred to using a function
name and arguments. global variable
A variable that is available to all JavaScript code in a web page.
It is declared (first used) outside any function. Greasemonkey
An extension for the Firefox browser that allows user scripts to
modify the appearance and behavior of web pages. Hypertext Markup Language (HTML)
The language used in web documents.
JavaScript statements are not HTML, but can be included within an HTML document. increment
To increase the value of a variable by one. In JavaScript, this is done
with the increment operator, ++.
scope
interpreter
The browser component that interprets JavaScript statements and acts
on them. Java
An object-oriented language developed by Sun Microsystems. Java applets
can be embedded within a web page. JavaScript has similar syntax, but is not the same as Java. JavaScript
A scripting language for web documents, loosely based on Java’s syn-
tax, developed by Netscape. JavaScript is now supported by the most popular browsers. layer
An area of a web page that can be positioned and can overlap other sec-
tions in defined ways. Layers are also known as positionable elements. local variable
A variable that is available to only one function. It is declared (first
used) within the function. loop
A set of JavaScript statements that are executed a number of times, or until a
certain condition is met. method
A specialized type of function that can be stored in an object, and acts on
the object’s properties. Navigator node
A browser developed by Netscape, and the first to support JavaScript.
In the DOM, an individual container or element within a web document.
Each HTML tag defines a node. object
A type of variable that can store multiple values, called properties, and
functions, called methods. operator
A character used to divide variables or constants used in an expression.
parameter
A variable sent to a function when it is called, also known as an argu-
ment. progressive enhancement
The approach of building a basic page that works on
all browsers, and then adding features such as scripting that will work on newer browsers without compromising the basic functionality of the page. property
A variable that is stored as part of an object. Each object can have any
number of properties. rule
In CSS, an individual element of a style block that specifies the style for an
HTML tag, class, or identifier. scope
The part of a JavaScript program that a variable was declared in and is
available to.
417
418
APPENDIX C: Glossary
selector
In a CSS rule, the first portion of the rule that specifies the HTML tag,
class, or identifier that the rule will affect. statement string tag
A single line of a script or program.
A group of text characters that can be stored in a variable.
In HTML, an individual element within a web document. HTML tags are con-
tained within angle brackets, as in and . text node
In the DOM, a node that stores a text value rather than an HTML ele-
ment. Nodes that contain text, such as paragraphs, have a text node as a child node. unobtrusive scripting
A set of techniques that make JavaScript accessible and
avoid trouble with browsers by separating content, presentation, and behavior. variable
A container, referred to with a name, that can store a number, a string,
or an object. VBScript
A scripting language developed by Microsoft, with syntax based on
Visual Basic. VBScript is supported only by Microsoft Internet Explorer. World Wide Web Consortium (W3C)
An international organization that develops
and maintains the standards for HTML, CSS, and other key web technologies. XHTML (Extensible Hypertext Markup Language)
A new version of HTML
developed by the W3C. XHTML is similar to HTML, but conforms to the XML specification. XML (Extensible Markup Language)
A generic language developed by the W3C
(World Wide Web Consortium) that allows the creation of standardized HTML-like languages, using a DTD (Document Type Definition) to specify tags and attributes.
APPENDIX D
JavaScript Quick Reference This appendix is a quick reference for the JavaScript language. It includes the built-in objects and the objects in the basic object hierarchy, JavaScript statements, and built-in functions.
Built-in Objects The following objects are built in to JavaScript. Some can be used to create objects of your own; others can only be used as they are. Each is detailed in the following sections.
Array You can create a new array object to define an array—a numbered list of variables. (Unlike other variables, arrays must be declared.) Use the new keyword to define an array, as in this example: students = new Array(30)
Items in the array are indexed beginning with 0. Refer to items in the array with brackets: fifth = students[4];
Arrays have a single property, length, which gives the current number of elements in the array. They have the following methods:
. . .
join quickly joins all of the array’s elements together, resulting in a string. The elements are separated by commas, or by the separator you specify. reverse returns a reversed version of the array. sort returns a sorted version of the array. Normally this is an alphabetical sort; however, you can use a custom sort method by specifying a comparison routine.
String Any string of characters in JavaScript is a string object. The following statement assigns a variable to a string value: text = “This is a test.”
Because strings are objects, you can also create a new string with the new keyword: text = new String(“This is a test.”);
420
APPENDIX D: JavaScript Quick Reference
String objects have a single property, length, which reflects the current length of the string. There are a variety of methods available to work with strings:
.
substring returns a portion of the string.
.
toUpperCase converts all characters in the string to uppercase.
.
toLowerCase converts all characters in the string to lowercase.
.
indexOf finds an occurrence of a string within the string.
.
lastIndexOf finds an occurrence of a string within the string, starting at the
end of the string.
.
link creates an HTML link using the string’s text.
.
anchor creates an HTML anchor within the current page.
There are also a few methods that allow you to change a string’s appearance when it appears in an HTML document:
.
string.big displays big text using the tag in HTML 3.0.
.
string.blink displays blinking text using the