JavaScript: The Complete Reference, Second Edition

This section lists the JavaScript objects as well as their properties, methods , and support. The object entries include all or some of the following information:

When describing methods and properties, the descriptions shown in Table B-1 are sometimes used.

Table B-1: Attributes Occasionally Used to Describe Properties or Methods

Descriptions

Meaning

Non-enumerable

The method or property will not be enumerated in a for/in loop. By default, methods are not enumerated. Event handlers are also not enumerated in Netscape.

Read-only

The property value is read-only and may not be changed.

Static

The property or method is a static (class) property of the object. Such properties and methods are accessed through their constructor rather than through an instance. For example, all properties of the Math object are static, so are accessed as Math. property .

The most important Document object in the reference is discussed first. Most of the Document objects will back reference it.

Note  

There is a great deal of Internet Explorer “specific JavaScript information that would fill three books this size to be found at msdn.microsoft.com (The Microsoft Developer's Network). In particular, http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/dhtml.asp is (currently) the link for Microsoft s DHTML documentation. Under it you can find the DHTML Reference, a list of Internet Explorer “supported objects and their properties and methods. We include all the major objects in the appendix, but there are numerous obscure IE-only features, details, and quirks to be found sifting through the voluminous online documentation.

Generic HTML Element Object (Document Object)

Generic (X)HTML elements have the form described here. This list of properties, methods, and event handlers are common to almost all (X)HTML element objects and are, in fact, the only properties, methods, and event handlers defined for a large number of very basic elements, such as < b >, < i >, and < u >. Each of these objects corresponds to an occurrence of an (X)HTML element on the page. Access to one of these objects is achieved through standard DOM methods like document.getElementById() .

Note  

Some properties do not have a well-defined meaning for particular objects, even though the properties may be defined for them. For example, blurring an < hr > tag is interesting given that it is difficult to focus the object in general Web use.

Properties

Methods

This method is often used with events to determine where user activity is taking place with respect to a particular element and to take special actions based on scroll bar manipulation. (IE5+)

There is no standard DOM method that mimics this behavior. Instead, you must examine the previousSibling , firstChild , lastChild , or nextSibling (in order corresponding to the values of where in the preceding table) and extract the string manually from their text node(s). (IE5+)

Notes

a, Anchor, Link, HTMLAnchorElement (Document Object)

In traditional models, there was a separate object for an < a > tag that specified a name attribute (called an Anchor ) and one that specified an href attribute (called a Link ). This nomenclature is outdated , and with the rise of the DOM there is no distinction. Modern browsers typically mesh Anchor and Link into a more appropriate object, which corresponds to any < a > element on the page, and fill in the Anchor - or Link - related properties if they are defined. In the following list, we note explicitly those properties and methods that are available only in Anchor or Link in traditional object models.

Access to these objects is achieved through standard DOM methods like document.getElementById() . However, you can also access those < a > elements with name attribute set through the anchors[] collection of the Document , and those elements with href attribute through the links[] collection.

Properties

This object has the following properties in addition to those in the Generic HTML Element object listed at the beginning of this appendix:

Methods

This object has the methods listed in the Generic HTML Element object found at the beginning of this appendix, in addition to the following:

Support

Supported in Internet Explorer 3+, Netscape 2+, Mozilla, DOM1.

abbr, HTMLElement (Document Object)

This object corresponds to an < abbr > (abbreviation) tag in the document. Access to this object is achieved through standard DOM methods such as document.getElementById() .

Properties

This object only has the properties defined by the Generic HTML Element object found at the beginning of this section.

Methods

This object only has the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in IE4+, MOZ/N6+, DOM1.

Notes

You may see browsers like Mozilla identify this object as an HTMLSpanElement though no such object exists in the DOM. The correct indication is HTMLElement , though Internet Explorer just indicates it as a generic object.

acronym, HTMLElement (Document Object)

This object corresponds to an < acronym > tag in the document. Access to this object is achieved through standard DOM methods such as document.getElementById() .

Properties

This object only has the properties defined by the Generic HTML Element object found at the beginning of this section.

Methods

This object only has the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in IE4+, MOZ/N6+, DOM1.

Notes

You may see browsers like Mozilla identify this object as an HTMLSpanElement though no such object exists in the DOM. The correct indication is HTMLElement , though Internet Explorer just indicates it as a generic object.

ActiveXObject (Proprietary Built-In Object)

The ActiveXObject object provides access to extended operating system or application functionality by permitting the instantiation of COM objects in Windows . We touch on this object in Chapter 21, but for full documentation of this object see Microsoft s documentation at MSDN.

Constructor

var instanceName = new ActiveXObject( " servername .typename" );

The servername is the name of the Automation server that implements the COM object typename .

Support

Supported in IE3+ (JScript 1.0+).

Notes

This is not an ECMAScript object. It is a proprietary Microsoft built-in object.

address, HTMLElement (Document Object)

This object corresponds to an < address > tag in the document. Access to this object is achieved through standard DOM methods such as document.getElementById() .

Properties

This object only has the properties defined by the Generic HTML Element object found at the beginning of this section.

Methods

This object only has the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in IE4+, MOZ/N6+, DOM1.

Notes

You may see browsers like Mozilla identify this object as an HTMLSpanElement though no such object exists in the DOM. The correct indication is HTMLElement , though Internet Explorer just indicates it as a generic object.

applet, HTMLAppletElement (Document Object)

An applet object corresponds to an < applet > (Java applet) tag in the document. Access to this object is achieved through standard DOM methods (for example, document.getElementById() ) or through the applets[] collection of the Document .

Properties

This object has the properties listed here, in addition to those in the Generic HTML Element object found at the beginning of this section. It will also have any public properties exposed by the class.

Methods

This object has the methods listed in the Generic HTML Element object found at the beginning of this section. It will also have any public methods exposed by the applet. See Chapter 18 for an example of this.

Support

Supported in Internet Explorer 4+, Netscape 3+, Mozilla, DOM1.

area, HTMLAreaElement (Document Object)

This object corresponds to an < area > (client-side image map) tag in the document. Access to this object is achieved through standard DOM methods (for example, document.getElementById() or via the areas[] array for an enclosing HTMLMapElement object). Most browsers should also show area objects within the links[] array of the Document .

Properties

This object has the following properties, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This object has the methods listed in the Generic HTML Element object found at the beginning of this section, in addition to the following:

Support

Supported in Internet Explorer 3+, Netscape 3+, Mozilla, DOM1.

Array (Built-in Object)

Array s store ordered lists of data. Data is stored at indices enumerated beginning with zero, which are accessed using the array access ( [] ) operator. Allocation of array memory is handled by the interpreter, so there is no need to explicitly resize arrays to accommodate more data. In addition, arrays are permitted to be sparse, that is, to have holes consisting of an arbitrary number of unused indices. Any index that has not been assigned data has value undefined , and the highest index addressable is 232 “1 because indices are converted to unsigned 32-bit integers before use. JavaScript arrays are one-dimensional, but since array elements can be of any type, multidimensional arrays are supported as arrays with elements that are arrays.

You can explicitly remove a value from an array using the delete operator, but there is no way to destroy an array other than by setting the variable that holds its reference to null .

Constructor

var instanceName = new Array([ val1 [, val2 [, val3 ... ] ] ]);

where the comma-separated values are treated as initial values for array indices 0 , 1 , 2 , and so on. The exception is if a single numeric parameter is supplied, in which case the array s length property is set to this value.

Properties

Methods

Support

Supported in IE4+ (JScript 2.0+), Mozilla, N3+ (JavaScript 1.1+), ECMAScript Edition 1.

Notes

In Netscape 4.0 “4.05 (JavaScript 1.2) a single numeric parameter to the constructor is added to the single array element ”it is not treated as an initial value for length .

See Chapter 7 for numerous examples of the Array object.

b, HTMLElement (Document Object)

This object corresponds to a < b > (bold weight text) tag in the document. Access to this object is achieved through standard DOM methods such as document.getElementById() .

Properties

This object only has the properties defined by the Generic HTML Element object found at the beginning of this section.

Methods

This object only has the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in IE4+, MOZ/N6+, DOM1.

Notes

You may see browsers like Mozilla identify this object as an HTMLSpanElement though no such object exists in the DOM. The correct indication is HTMLElement , though Internet Explorer just indicates it as a generic object.

base, HTMLBaseElement (Document Object)

This object corresponds to a < base > (base URL indicator) tag in the document. Access to this object is achieved through standard DOM methods such as document.getElementById() . However, because this element is found in the document head, you might need to use document.documentElement.getElementsByTagName() or a similar method to access it.

Properties

This object has the following properties, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This object only has those methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla, Netscape 6+, DOM1.

baseFont, HTMLBaseFontElement (Document Object)

This object corresponds to a < basefont > (default font) tag in the document. Access to this object is achieved through standard DOM methods such as document.getElementById() . However, because this element is found in the document head, you might need to use document.documentElement.getElementsByTagName() or a similar method to achieve access to it.

Properties

This object has the following properties, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This element only has the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Deprecated in HTML 4 and XHTML, but supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

bdo, HTMLElement (Document Object)

This object corresponds to a < bdo > (bidirectional override) tag in the document. Access to this object is achieved through standard DOM methods such as document.getElementById() .

Properties

This object only has the properties defined by the Generic HTML Element object found at the beginning of this section.

Methods

This object only has the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 5+, Mozilla/Netscape 6+ DOM1.

Notes

You may see browsers like Mozilla identify this object as an HTMLSpanElement though no such object exists in the DOM. The correct indication is HTMLElement , though Internet Explorer just indicates it as a generic object.

bgSound (Proprietary Document Object)

This object corresponds to a < bgsound > (background sound) tag in the document. Given this is a proprietary Internet Explorer tag, access is generally handled with document.all[] . However, under IE you should also be able to access it via standard DOM methods such as document.getElementById() .

Properties

For supporting browsers like Internet Explorer, this object has the following properties, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This object has the methods listed in the Generic HTML Element object found at the beginning of this section, despite being a proprietary object.

Support

Internet Explorer 4+.

big, HTMLElement (Document Object)

This object corresponds to a < big > (increased font size) tag in the document. Access to this object is achieved through standard DOM methods such as document.getElementById() .

Properties

This object only has the properties defined by the Generic HTML Element object found at the beginning of this section.

Methods

This object only has the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

Notes

You may see browsers like Mozilla identify this object as an HTMLSpanElement though no such object exists in the DOM. The correct indication is HTMLElement , though Internet Explorer just indicates it as a generic object.

blockQuote, HTMLQuoteElement (Document Object)

This object corresponds to a < blockquote > tag in the document. Access to this object is achieved through standard DOM methods such as document.getElementById() .

Properties

This object has the following property, in addition to those in the Generic HTML Element object found at the beginning of this section.

Methods

This object only has the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

Notes

The DOM defines HTMLQuoteElement to cover objects related to < q > and < blockquote >. Some browsers also recognize < bq > as well to instantiate this type of object.

Mozilla and Opera 7.5+ correctly identify this object as HTMLQuoteElement while Internet Explorer reports it as a generic object. Opera 7.5+ also recognizes the ad hoc < bq > syntax as HTMLQuoteElement .

body, HTMLBodyElement (Document Object)

This object corresponds to the < body > tag in the document. Access to this object is often via document.body though other DOM methods like document.getElementById() can be used.

Properties

This object has the following properties, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This object has the following methods, in addition to those in the Generic HTML Element object found at the beginning of this section:

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

Notes

Traditionally, many of the document-level features like colors were modified via the propreties of the Document object so developers may often favor them over changing the values directly via the HTMLBodyElement .

Boolean (Built-in Object)

Boolean is the container object for the primitive Boolean data type. It is not, however, recommendable to use Boolean objects unless you have a good reason for doing so. The reason is that any object that is not undefined or null is converted to the true primitive Boolean value when used in a conditional. This means that a Boolean object instance with value false will evaluate true in a conditional, not false as you might expect. It is therefore important to remember to use this object s valueOf() method to extract the appropriate primitive Boolean value of Boolean objects in conditionals.

Constructor

var instanceName = new Boolean( initialValue );

where initialValue is data that will be converted into a Boolean ”for example, a string, primitive Boolean value, or number. If initialValue is false , null , NaN , undefined , 0 , the empty string, or if initialValue is omitted, the newly created object has value false . Otherwise, the initial value is true .

Properties

Methods

Support

Supported in IE3+ (JScript 1.0+), Mozilla, N3+ (JavaScript 1.1+), ECMAScript Edition 1.

Notes

Versions of Netscape prior to 4.06 (and language versions prior to JavaScript 1.3) convert Boolean objects with value false to the primitive false in conditionals. Modern implementations convert such objects to true .

See Chapters 3 and 7 for examples using Boolean .

br, HTMLBRElement (Document Object)

This document object corresponds to a < br > (linebreak) tag in the document. Access to this object is achieved through standard DOM methods such as document.getElementsByTagName() .

Properties

This object has the following property, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This object only has the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

button, HTMLButtonElement (Document Object)

This object corresponds to a < button > tag in the document. It does not correspond to an occurrence of < input type="button" > (see Button immediately following). Access to this object is achieved through standard DOM methods such as document.getElementById() or more commonly through the elements[] array of a Form object.

Properties

This object has the following properties, in addition to those in the Generic HTML Element object found at the beginning of this section.

Methods

This object only has the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+ (< button > tags are not supported in Netscape 4), DOM1.

Button, HTMLInputElement (Document Object)

This object corresponds to an < input type="button" / > tag in the document. It does not correspond to an occurrence of < button > (see button , immediately preceding). Access to this object is achieved through standard DOM methods such as document.getElementById() but is more commonly performed via the elements[] array of the form it is contained in.

Properties

This object has the following properties, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This object has the following methods, in addition to those in the Generic HTML Element object found at the beginning of this section:

Support

Supported in Internet Explorer 3+, Mozilla, Netscape 2+, DOM1.

caption, HTMLTableCaptionElement (Document Object)

This object corresponds to a < caption > (table caption) tag in the document. Access to this object is achieved through standard DOM methods like document.getElementById() or through the HTMLTableObject (< table >) it is enclosed within.

Properties

This object has the following properties, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This object only has the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

center, HTMLElement (Document Object)

This object corresponds to a < center > (centered text) tag in the document. Access to this object is achieved through standard DOM methods such as document.getElementById() .

Properties

This object only has the properties defined by the Generic HTML Element object found at the beginning of this section.

Methods

This object only has the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

Notes

You may see browsers like Mozilla identify this object as an HTMLSpanElement though no such object exists in the DOM. The correct indication is HTMLElement , though Internet Explorer just indicates it as a generic object.

Checkbox, HTMLInputElement (Document Object)

This object corresponds to an < input type="checkbox" / > tag in the document. Access to this object is achieved through standard DOM methods (for example, document.getElementById() ) or more commonly through the elements[] array of the form it is contained in.

Properties

This object has the following properties, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This object has the following methods, in addition to those in the Generic HTML Element object found at the beginning of this section:

Support

Supported in Internet Explorer 3+, Mozilla, Netscape 2+, DOM1.

cite, HTMLElement (Document Object)

This object corresponds to a < cite > (citation) tag in the document. Access to this object is achieved through standard DOM methods such as document.getElementById() .

Properties

This object only has the properties defined by the Generic HTML Element object found at the beginning of this section.

Methods

This object only has the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

Notes

You may see browsers like Mozilla identify this object as an HTMLSpanElement though no such object exists in the DOM. The correct indication is HTMLElement , though Internet Explorer just indicates it as a generic object.

clientInformation (Proprietary Browser Object)

The clientInformation object is just a synonym for the browser s Navigator object. Microsoft provides it in IE4+ in order not to use Netscape s Navigator name, although, of course, IE still supports the Navigator object directly. You should avoid using clientInformation and opt for Navigator instead, since it is far more cross-browser compatible.

clipboardData (Proprietary Browser Object)

The clipboardData object provides an interface for interacting with Windows system clipboard.

Properties

None.

Methods

Support

Internet Explorer 5+ for Windows.

code, HTMLElement (Document Object)

This object corresponds to a < code > (code listing) tag in the document. The object is accessed via standard DOM methods like document.getElementById() .

Properties

This object only has the properties defined by the Generic HTML Element object found at the beginning of this section.

Methods

This object only has the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

Notes

You may see browsers like Mozilla identify this object as an HTMLSpanElement though no such object exists in the DOM. The correct indication is HTMLElement , though Internet Explorer just indicates it as a generic object.

col, HTMLTableColElement (Document Object)

This object corresponds to a < col > (table column) tag in the document. Access to this object is achieved through standard DOM methods like document.getElementById() or through the HTMLTableObject (< table >) it is enclosed within.

Properties

This object has the following properties, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This object only has the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

colGroup, HTMLTableColElement (Document Object)

This object corresponds to a < colgroup > (table column group) tag in the document. Access to this object is achieved through standard DOM methods like document.getElementById() . This object has structure identical to col .

Properties

This object only has the properties defined by the Generic HTML Element object found at the beginning of this section.

Methods

This object only has the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

CSSrule (Document Object)

See rule object.

currentStyle (Proprietary Document Object)

This is a read-only Style object that reflects all styles that are applied to the element, regardless of where their definitions are. Because the normal Style object reflects only inline style set with the style attribute, the normal Style object as accessed through element. style does not reflect styles set by default or through externally linked style sheets. The currentStyle object does , and is updated dynamically as the styles applied to the element change. See Style object for more details.

Support

Internet Explorer 5+.

dataTransfer (Proprietary Browser Object)

This Internet Explorer “specific object is a child of an Event object and provides access to predefined clipboard formats that are used in drag-and-drop operations. A summary of the properties and methods is presented here. See MSDN for more details.

Properties

Methods

Support

IE 5+

Date (Built-in Object)

The Date object provides a wide variety of methods for manipulating dates and times. It is important to remember that Date instances do not contain a ticking clock but rather hold a static date value. Internally, the date is stored as the number of milliseconds since the epoch (midnight of January 1, 1970 UTC). This accounts for the prominent role of milliseconds in many Date methods.

Milliseconds, seconds, minutes, hours, and months are enumerated beginning with zero; so, for example, December is month 11. Days are enumerated beginning with 1. Years should always be given using four digits. Modern implementations permit years as much as several hundred thousand years in the past or future, although older implementations often have trouble handling dates before 1970. Many implementations have trouble handling dates before 1 A.D.

Note that Universal Coordinated Time (UTC) is the same as Greenwich Mean Time (GMT).

Constructor

var instanceName = new Date();

var instanceName = new Date( milliseconds );

var instanceName = new Date( stringDate );

var instanceName = new Date( year , month , day [, hrs [, mins [, secs [, ms ]]]]);

The first constructor syntax creates a new Date instance holding the current date and time. The second syntax creates an instance holding the date given by the number of milliseconds given in the numeric milliseconds argument. The third syntax attempts to create an instance by converting the string stringDate into a valid date using the parse() method (see under the Methods section). The fourth syntax creates an instance according to its numeric arguments. If the optional parameters are omitted, they are filled with zero.

Properties

Methods

Support

Supported in IE3+ (JScript 1.0+), Mozilla, N2+ (JavaScript 1.0+), ECMAScript Edition 1.

Notes

The Date object is seriously broken in older browsers. The authors suggest avoiding its use except in the most basic tasks in browsers earlier than IE4 and Netscape 4.

The Date object cannot be enumerated directly using for/in .

dd, HTMLElement (Document Object)

This object corresponds to a < dd > (definition in a definition list) tag in the document. Access to this object is achieved through standard DOM methods such as document.getElementById() .

Properties

This object only has the properties defined by the Generic HTML Element object found at the beginning of this section.

Methods

This object only has the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

Notes

You may see browsers like Mozilla identify this object as an HTMLSpanElement though no such object exists in the DOM. The correct indication is HTMLElement , though Internet Explorer just indicates it as a generic object.

del, HTMLModElement (Document Object)

This object corresponds to a < del > (deletion modification) tag in the document. Access to this object is achieved through standard DOM methods such as document.getElementById() .

Properties

This object has the following properties, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This object only has the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

Notes

This object is the same as the one associated with the < ins > tag as under the DOM both are HTMLModElement objects. We break them out separately as developers familiar with (X)HTML will consider them to have different meanings.

dfn, HTMLElement (Document Object)

This object corresponds to a < dfn > ( term definition) tag in the document. It has the properties, methods, and events listed in the Generic HTML Element object found at the beginning of this section. Access to this object is achieved through standard DOM methods such as document.getElementById() .

Properties

This object only has the properties defined by the Generic HTML Element object found at the beginning of this section.

Methods

This object only has the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

Notes

You may see browsers like Mozilla identify this object as an HTMLSpanElement though no such object exists in the DOM. The correct indication is HTMLElement , though Internet Explorer just indicates it as a generic object.

dir, HTMLDirectoryElement (Document Object)

This object corresponds to a < dir > (directory listing) element in the document. It has the properties, methods, and events listed in the Generic HTML Element object found at the beginning of this section. Access to this object is achieved through standard DOM methods such as document.getElementById() .

Properties

This object has the following property, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This object only has the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

div, HTMLDivElement (Document Object)

This object corresponds to a < div > (block container) element in the document. Access to this object is achieved through standard DOM methods such as document.getElementById() .

Properties

This object has the following properties, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This object has the following method, in addition to those in the Generic HTML Element object found at the beginning of this section:

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

dl, HTMLDListElement (Document Object)

This object corresponds to a < dl > (definition list) tag in the document. Access to this object is achieved through standard DOM methods such as document.getElementById() .

Properties

This object has the following property, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This object only has the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

Document (Document Object)

The Document provides access to the contents of the HTML document currently loaded. In early browsers, this was primarily a browser object because there was no standard governing its structure. With the rise of the DOM, this object has become standardized, although modern browsers continue to provide a multitude of proprietary features.

HTML elements in the page are represented as objects under the Document . Each such element object has properties and methods derived from a variety of sources. The most obvious of these are proprietary browser features, but elements also inherit properties and methods from the DOM Node interface, the DOM HTMLElement definition, and possibly more specific DOM objects. While the specific origin of a property is often not particularly important so long as the property is well supported, the reader should be aware that the structure of each element object is derived from a variety of sources.

The collections contained within the Document are in general read-only, although specific elements of the collections are often mutable.

Properties

Methods

Support

Supported in all major browsers: IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), DOM.

dt, HTMLElement (Document Object)

This object corresponds to a < dt > (term definition in a definition list) tag in the document. Access to this object is achieved through standard DOM methods like document.getElementById() .

Properties

This object has the following property, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This object has only the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

Notes

You may see browsers like Mozilla identify this object as an HTMLSpanElement though no such object exists in the DOM. The correct indication is HTMLElement , though Internet Explorer just indicates it as a generic object.

em, HTMLElement (Document Object)

This object corresponds to an < em > ( emphasized text) element in the document. Access to this object is achieved through standard DOM methods such as document.getElementById() .

Properties

This object only has the properties defined by the Generic HTML Element object found at the beginning of this section.

Methods

This object only has the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

Notes

You may see browsers like Mozilla identify this object as an HTMLSpanElement though no such object exists in the DOM. Internet Explorer just indicates it as a generic object.

embed (Proprietary Document Object)

This document object corresponds to an < embed > (embedded object) element in the document. Access to these objects is achieved through standard DOM methods such as document.getElementById() or more often via the embeds[] array of the Document .

Properties

This object has the properties listed here, in addition to those in the Generic HTML Element object found at the beginning of this section. It will also have any properties exposed by the plug-in used to handle the data (see plug-in vendor documentation).

Methods

This element has the methods listed in the Generic HTML Element object found at the beginning of this section. It also has any methods exposed by the plug-in used to handle the data ( consult plug-in vendor documentation).

Support

Supported in Internet Explorer 4+, Mozilla, Netscape 3 (primitive support ”only for those properties and methods exposed by the plug-in handling the data), Netscape 4+.

Notes

Despite being more common in public Web sites than Java applets, the < embed > tag and associated embed object are not part of a W3C standard at the time of this edition s writing.

Enumerator (Built-in Object)

Instances of this proprietary Microsoft object are used to iterate over items in a collection. Since collection items in Internet Explorer are not enumerated in for/in loops and are not otherwise directly accessible, you will need to use this object to ensure proper iteration over all items in a collection.

Constructor

var instanceName = new Enumerator( collection );

The constructor returns a new Enumerator instance that can be used to iterate over all the items in the collection given by collection . Typical values for collection are document.all and collections returned by methods like getElementsByTagName() .

Properties

None.

Methods

Support

Supported in IE4+ (JScript 3.0+).

Notes

This is not an ECMAScript object. It is a proprietary Microsoft built-in object.

Error (Built-in Object)

Whenever a runtime error occurs or an exception is thrown, the interpreter creates an Error instance that can be caught by the programmer. This object gives information about the error that occurred, including a description of the problem and the line number at which the error occurred. Error objects may also be instantiated by the programmer in order to create custom exceptions that can be thrown .

There are actually several types of error objects, but each is derived from the basic Error object and all have identical structure. The other error objects are EvalError , RangeError , ReferenceError , SyntaxError , TypeError , and URIError and browsers compliant with ECMAScript Edition 3 should provide constructors for all six, in addition to Error itself. Note, however, that programmers are encouraged to use the Error object and to leave the six native error types to be used exclusively by the interpreter.

Constructor

var instanceName = new Error( message );

The message string defines the text associated with the error and is often displayed to the user. Note that creating an Error does not cause it to be thrown; you need to use the throw statement explicitly.

Properties

Methods

Support

Supported in IE5+ (JScript 5.0+), MOZ/N6+ (JavaScript 1.5+), ECMAScript Edition 3.

Notes

Support for this object is spotty under Internet Explorer 5.0. For this reason the authors suggest restricting its use to ECMAScript Edition 3 “compliant browsers, such as Internet Explorer 5.5+, Mozilla, and Netscape 6+.

Event (Browser Object)

An instance of the Event object is made available to event handlers in three different ways. In IE, the instance is implicitly set as a Window property called event , so it can be accessed throughout the document simply as event . In Netscape and under DOM2, the Event is available as event in handlers bound to elements via HTML attributes. Handlers bound using Netscape or DOM methods or by setting the appropriate property with JavaScript are passed the Event instance as an argument.

Not all properties are defined for every event; for example, Event instances corresponding to keyboard events do not include mouse position properties.

Properties

Methods

There are a variety of methods related to handling events that vary significantly from browser to browser. Chapter 11 covered this in great detail. We summarize most of the important issues here grouped by browser.

Internet Explorer Event Methods

The following are the event-related methods supported in Internet Explorer. For a description of Internet Explorer s object model, see Chapter 11.

attachEvent( whichHandler, theFunction ) Attaches the function theFunction as a handler specified by the string whichHandler . The whichHandler argument specifies the name of the event handler that is to execute theFunction upon firing. For example, to attach myHandler as an onclick handler for the Document, you would write

document.attachEvent("onclick", myHandler);

Handlers attached using this method are executed after any handler that was set as an HTML attribute or directly into the appropriate on property of the object. Multiple handlers can be attached using this method, but no guarantee is made as to their order of execution. This method returns a Boolean indicating whether the attachment was successful. Supported in IE5+ (JScript 5.0+).

detachEvent( whichHandler, theFunction ) Instructs the object to cease executing the function theFunction as a handler for the event given in the string whichHandler . This method is used to detach handlers applied to objects using attachEvent() . For example, to detach the function myHandler that was attached as an onclick handler for the Document (using attachEvent() ), you would use

document.detachEvent("onclick", myHandler);

Supported in IE5+ (JScript 5.0+).

fireEvent( handler [, event ]) Causes the event handler given by the string handler of the object to fire. If an Event instance is supplied as the event parameter, the Event instance passed to the target object s handler reflects the properties of event . This method returns true or false depending upon whether the event was eventually canceled . Events created in this manner follow the normal bubbling and cancelation rules for the event created. This method is used to redirect an event to a new target (or to create a brand new event at that target) by invoking it as a method of that target. For example, to fire the onclick handler of the first image on the page, you might write

document.images[0].fireEvent("onclick");

Note that the srcElement of the Event instance created is set to the object of which this method was invoked, whether the event parameter was supplied or not. Supported in IE5.5+ (JScript 5.5+).

releaseCapture() Disables universal mouse event capturing that was enabled using setCapture() . If this method is invoked as a method of the Document , whichever element that is currently capturing all mouse events will cease to do so. You can, of course, invoke this function as a method of the object that is capturing to the same effect. However the ability to invoke it on the Document frees the programmer from determining exactly which element is currently capturing. Invoking this method when no element is universally capturing mouse events has no effect. Supported in IE5+ (JScript 5.0+).

setCapture([ containerCapture ]) Causes all mouse events that occur in the document to be sent to this object. The srcElement of the Event instance will always reflect the original target of the event, but all other handlers and bubbling are bypassed. In Internet Explorer 5.5+ you can specify containerCapture to be false , which causes mouse events contained by the element to function normally. However, mouse events outside the element are still unconditionally captured. This method is used to direct all mouse events to an object when that object could not otherwise capture them. For example, if there are elements whose mouse events need to be captured but those elements are not the children of the object, you need to use this method because bubbling events from the other elements would not reach it. Note that capturing is automatically disabled when the user scrolls the page, gives focus to another window, uses a dialog box, or activates a context menu. For this reason, it is always a good idea to set the Document s onlosecapture handler to re-enable capture if you wish to keep it on. Supported in IE5+ (JScript 5.0+).

Netscape Event Methods

The following are the event-related methods supported in the Netscape 4 family of browsers. For a description of the Netscape 4 event model, see Chapter 11.

captureEvents( eventMask ) Instructs the object of which it was invoked as a method ( Layer , Window , or Document ) to capture the events given in eventMask . Note that you must still manually set the appropriate handler of the object (for example, document.onunload ) to the function that it is to execute when the event occurs. The eventMask argument is a bitmask of static properties of the Event object, and these properties are given in the table that follows . For example, to capture submit and reset events at the Document you might write

document.captureEvents(Event.SUBMIT & Event.RESET);

The following table indicates the possible bitmask values for eventMask . They are accessed as static values of the Event object.

ABORT

ERROR

MOUSEDOWN

RESET

BLUR

FOCUS

MOUSEMOVE

RESIZE

CHANGE

KEYDOWN

MOUESEOUT

SELECT

CLICK

KEYPRESS

MOUSEOVER

SUBMIT

DBLCLICK

KEYUP

MOUSEUP

UNLOAD

DRAGDROP

LOAD

MOVE

 

handleEvent( event ) Fires the event handler of the object according to the Event instance event that was passed as an argument. This method is invoked in order to redirect the event to the object it was invoked as a method of. For example, an onsubmit handler for a form could pass the submit event to the first form on the page as

<form onsubmit="document.forms[0].handleEvent(event)"></form>

Supported in N4 (JavaScript 1.2).

releaseEvents( eventMask ) Instructs the object of which it was invoked as a method ( Layer , Window , or Document ) to stop capturing the events given in eventMask . After using this method you do not have to reset the object s event handlers that were released, because the object will cease to capture the events, even if it has a handler defined. The eventMask is a bitmask of static properties defined in the Event object in the table for captureEvents() given previously in this section. For example, to cease capture of error and click events at the Document level, you would use

document.releaseEvents(Event.ERROR & Event.CLICK);

Supported in N4+ (JavaScript 1.2+).

routeEvent( event ) Passes the Event instance event along normally down the object hierarchy for processing. This method is used by a Layer , Window , or Document to elect not to handle the specific event. For example, if the event was captured and after examination determined not to be of interest, this method is invoked to pass the event on down the hierarchy for (possibly) other handlers to process. Supported in N4+ (JavaScript 1.2+).

DOM2 Event Methods

The following methods are common to many (if not all) nodes under the DOM. The full specification can be found at http://www.w3.org/DOM/ .

addEventListener( whichEvent , handler , direction ) Instructs the object to execute function handler when an event of the type given in the string whichEvent (for example, "click") occurs. The direction parameter is a Boolean indicating whether the handler should be fired in the capture phase ( true ) or bubbling phase ( false ). Multiple handlers for the same event can be attached by using this method multiple times. Listeners (event handlers) can be bound to text nodes as well as element nodes. Supported in N6+ (JavaScript 1.5+), DOM2.

dispatchEvent( event ) Causes the Event instance event to be processed by the appropriate handler of the object that this function was invoked as a method of. This method returns false if any handler that eventually processes the event returns false or invokes preventDefault() . The node at which this method was invoked becomes the new target of event . This method is used to redirect an event to another node in the tree. Supported in N6+ (JavaScript 1.5+), DOM2.

preventDefault() When invoked in a handler this method has the effect of canceling the default action associated with the event. Calling this method is the same as returning false from a handler. Note that in DOM2 once a handler has returned false or invoked this method, the default action associated with the event will not occur, no matter what value other handlers that process the event return. Supported in N6+ (JavaScript 1.5+), DOM2.

removeEventListener( whichEvent, handler, direction ) Removes the function handler as a handler for the event given in the string whichEvent (for example, "click") for the phase given by the Boolean direction . Note that direction must correspond to the value passed as the third parameter to addEventListener() when the handler was originally attached to the object. Supported in N6+ (JavaScript 1.5+), DOM2.

stopPropagation() When invoked in an event handler, halts the normal propagation of the event after the current handler completes execution. This method works only for those events that are cancelable. Supported in N6+ (JavaScript 1.5+), DOM2.

Notes

You can set most properties of Event instances in Netscape if you have the UniversalBrowserWrite privilege (see Chapter 22). Also, most IE properties listed above are read-only in IE4, but mutable in IE5+.

Event Handlers

Event handlers are JavaScript code that are associated with an object and that fire in response to a user or system event on that object. Document objects typically support numerous event handlers encompassing a wide range of user actions in addition to intrinsic or system events that occur in response to a browser or DOM event such as the page completing loading. Some browser objects, most notably Window , also support a variety of handlers that allow it to process events for any document it contains, for example, if the window is made up of multiple frames.

HTML 4 Events

The standard HTML 4 events are listed here. According to the event model of Internet Explorer 4+, some events may be canceled and some events bubble up the hierarchy. The behavior of each of the HTML 4 events under Internet Explorer 4+ is indicated along with its associated handler (for example, the behavior of the blur event is given with the onblur handler).

DOM Events

DOM2 supports the standard HTML 4 events. Their behavior under the DOM2 event model is given in the following table.

Event

Bubbles?

Cancelable?

Abort

Yes

No

Blur

No

No

change

Yes

No

Click

Yes

Yes

Error

Yes

No

Focus

No

No

Load

No

No

mousedown

Yes

Yes

mouseup

Yes

Yes

mouseover

Yes

Yes

mousemove

Yes

Yes

Reset

Yes

No

Resize

Yes

No

Scroll

Yes

No

Select

Yes

No

Submit

Yes

Yes

Unload

No

No

DOM2 also supports document mutation events that occur on portions of the document tree and GUI events that permit arbitrary elements to have an equivalent to the onfocusin / onfocusout handlers defined for form fields. These events should be bound using standard DOM methods, as support for the corresponding event handler properties is nonexistent. The mutation events are listed in the following table.

Event

Bubbles?

Cancelable?

Description

DOMFocusIn

Yes

No

Fires on a node when it receives focus.

DOMFocusOut

Yes

No

Fires on a node when it loses focus.

DOMSubtreeModified

Yes

No

Implementation-dependent; fires when a portion of the node s subtree has been modified.

DOMNodeInserted

Yes

No

Fires on a node inserted as the child of another node.

DOMNodeRemoved

Yes

No

Fires on a node that has been removed from its parent.

DOMNodeRemovedFromDocument

No

No

Fires on a node when it is about to be removed from the document.

DOMNodeInsertedIntoDocument

No

No

Fires on a node when it has been inserted into the document.

DOMAttrModified

Yes

No

Fires on a node when one of its attributes has been modified.

DOMCharacterDataModified

Yes

No

Fires on a node when the data it contains are modified.

Netscape Extended Events

The following events are not part of any standard, but are supported by Netscape browsers.

Internet Explorer Extended Events

The following events are not part of any standard, but are supported by Internet Explorer. According to the event model of Internet Explorer 4+, some events may be canceled and some events bubble up the hierarchy. The behavior of each of these extended events under Internet Explorer 4+ is indicated along with its associated handler (for example, the behavior of the abort event is given with the onabort handler).

external (Proprietary Browser Object)

This object provides methods for calling into native code. It is primarily used when IE is being used as a component, but can also be used in conjunction with Browser Helper Objects (BHOs) and to access certain browser features like adding a bookmark. For full details about this object see Microsoft's documentation at MSDN.

Properties

Methods

Support

IE4+

Notes

The use of this object is not encouraged as it is not only proprietary, but has significant security implications when misused.

fieldSet , HTMLFieldSetElement (Document Object)

This object corresponds to a < fieldset > (form field grouping) element in the document. Access to this object is achieved through standard DOM methods like document.getElementById() .

Properties

This object has the following property, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This object only has the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

File, FileUpload, HTMLInputElement (Document Object)

This object corresponds to an < input type="file" > element in the document. Access to this object is achieved through standard DOM methods (for example, document.getElementById() ) or more commonly through the elements[] array of the form it is contained in.

Properties

This object has the following properties, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This object has the following methods, in addition to those in the Generic HTML Element object found at the beginning of this section:

Support

Supported in Internet Explorer 4+, Mozilla, Netscape 3+, DOM1.

FileSystemObject (Proprietary Built-in Object)

This object provides access to the local filesystem to scripts in an IE/Windows environment (subject, of course, to security restrictions). For full documentation of this object see Microsoft s documentation at MSDN or see Chapter 21 for some basic examples.

Notes

This is not an ECMAScript object. It is a proprietary Microsoft built-in object.

font, HTMLFontElement (Document Object)

This object corresponds to a < font > element in the document. Access to this object is achieved through standard DOM methods such as document.getElementById() .

Properties

This object has the following properties, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This element only has the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

form, Form, HTMLFormElement (Document Object)

This object corresponds to a < form > tag in the document. Standard DOM methods can be used to access this object but more often the forms[] array of the Document is used.

Properties

This object has the following properties, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This object has the following methods, in addition to those in the Generic HTML Element object found at the beginning of this section:

Support

Supported in Internet Explorer 3+, Mozilla, Netscape 2+, and DOM1.

frame, HTMLFrameElement (Document Object)

This object corresponds to a < frame > element in the document. It does not correspond to the Frame object (of which the entries in document.frames[] are composed ). The distinction is that this object corresponds to an instance of the < frame > tag in the document whereas Frame corresponds to the Window object in which the frame s content actually appears. Standard DOM methods are used to access this object.

Properties

This object has the following properties, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This object has only the methods listed in the Generic HTML Element object found at the beginning of this section. The expected methods for handling the contents of frames are related to the Frame browser object, which acts like Window .

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

Frame (Browser Object)

This object corresponds to the (sub)window in which a frame s contents are displayed. It is not a < frame > element but is rather created as the result of one. Access to this object is achieved through the window.frames[] collection. This object has an identical structure to Window .

Properties

See Window .

Methods

See Window .

Support

Supported in Internet Explorer 3+, Mozilla, Netscape 2+.

frameSet, HTMLFrameSetElement (Document Object)

This object corresponds to a < frameset > element in the document. Access to this object is achieved through standard DOM methods such as document.getElementById() .

Properties

This object has the following properties, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This object only has the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

Function (Built-in Object)

Function is the object from which JavaScript functions are derived. Functions are first-class data types in JavaScript, so they may be assigned to variables and passed to functions as you would any other piece of data. Functions are, of course, reference types.

The Function object provides both static properties like length and properties that convey useful information during the execution of the function, for example, the arguments[] array.

Constructor

var instanceName = new Function([ arg1 [, arg2 [, ...]] ,] body );

The body parameter is a string containing the text that makes up the body of the function. The optional argN s are the names of the formal parameters the function accepts. For example:

var myAdd = new Function("x", "y", "return x + y"); var sum = myAdd(17, 34);

Properties

Methods

Support

Supported in IE4+ (JScript 2.0+), N3+ (JavaScript 1.1+), MOZ, ECMAScript Edition 1.

Notes

General examples of functions are found throughout the book, but see Chapter 5 for examples of the advanced aspects of functions and the Function object.

Global (Built-in Object)

The Global object provides methods and constants that can be used freely anywhere in your scripts. Global is defined to be the globally enclosing context, so this object cannot be instantiated or even directly accessed; its properties and methods are always within the scope of an executing script. Its sole purpose is as a catch-all for globally available methods and constants.

Constructor

This object cannot be instantiated because it defines the global context and thus has no constructor.

Properties

Methods

Support

Supported in IE3+ (JScript 1.0+), N2+ (JavaScript 1.0+), Mozilla, ECMAScript Edition 1.

head, HTMLHeadElement (Document Object)

This object corresponds to the < head > tag in the document. Access to this object is achieved through standard DOM methods, though since it typically does not have an id value it is often referenced by moving from a common starting point like document.documentElement .

Properties

This object has the following property, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This object only has the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1

Hidden, HTMLInputElement (Document Object)

This object corresponds to an occurrence of a hidden form field (< input type="hidden" >) in the document. This object can be accessed using standard DOM methods such as document.getElementById() or through the Form element that contains it (via the elements[] array or by name ). The structure of this object is nearly identical to the structure of the Text object, so see the reference for Text for details.

Properties

Same as Text object.

Methods

Same as Text object though it lacks the select() method since the element is not visible on screen.

Support

Supported in Internet Explorer 3+, Mozilla, Netscape 2+, DOM1.

History (Browser Object)

The browser keeps an array of recently visited URLs in the History object and provides script the means to navigate to them. This enables scripts to mimic the behavior of the browser s Forward and Back buttons as well as the ability to jump to the n th URL in the browser s history.

Properties

Methods

Support

Supported in IE3+ (JScript 1.0+), N2+ (JavaScript 1.0+), MOZ.

Notes

Netscape 2 keeps track of history information on a window-wide level while later versions of Netscape keep an individual history for each frame, so these methods should be employed with caution in Netscape 2 browsers.

Individual entries in the history array can be accessed as history[ i ] using signed scripts in Netscape but are otherwise unavailable for privacy reasons.

h1, h6 (Document Object)

This object corresponds to an < h n > (heading level n where heading level ranges from 1 to 6) element in the document. Access to this object is achieved through standard DOM methods such as document.getElementById() .

Properties

This object has the following property, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This object only has the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

hr, HTMLHRElement (Document Object)

This object corresponds to an < hr > (horizontal rule) tag in the document. Access to this object is achieved through standard DOM methods such as document.getElementById() .

Properties

This object has the following properties, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This object only has the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

html, HTMLHtmlElement (Document Object)

This object corresponds to the < html > element in the document. Access to this object is achieved through standard DOM methods, typically directly using document.documentElement .

Properties

This object has the following properties, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This object only supports the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla, Netscape 6+, DOM1.

I, HTMLElement (Document Object)

This object corresponds to an < i > (italics) tag in the document. Access to this object is achieved through standard DOM methods such as document.getElementById() .

Properties

This object only supports the properties listed in the Generic HTML Element object found at the beginning of this section.

Methods

This object only supports the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

Notes

You may see browsers like Mozilla identify this object as an HTMLSpanElement though no such object exists in the DOM. The correct indication is HTMLElement , though Internet Explorer just indicates it as a generic object.

iframe, HTMLIFrameElement (Document Object)

This object corresponds to an < iframe > (inline frame) tag in the document. Access to this object is achieved through standard DOM methods such as document.getElementById() . In the case of Internet Explorer access is often via the document.frames[] array.

Properties

This object has the following properties, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This object only has the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

Image, HTMLImageElement (Document Object)

An Image object corresponds to an < img > tag in the document. This object exposes properties that allow the dynamic examination and manipulation of images on the page. Access to an Image object is often achieved through the images[] collection of the Document , but the modern document.getElementById() method provided by the DOM can of course also be used.

Constructor

var instanceName = new Image([ width , height ]);

A new Image is created and returned with the given width and height , if specified. This constructor is useful for preloading images by instantiating an Image and setting its src earlier in the document than it is needed.

Properties

This object has the following properties, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This object has the following method, in addition to those in the Generic HTML Element object found at the beginning of this section:

Support

Supported in Internet Explorer 4+, Mozilla, Netscape 3+, DOM1.

implementation (Document Object)

Contains information about the DOM technologies the browser supports.

Properties

None.

Methods

Support

Supported in Internet Explorer 6+, Mozilla/Netscape 6+, DOM1 Core.

Notes

While primarily a browser object in what it provides, document.implementation is considered a Document object because it is part of the DOM specification.

input, HTMLInputElement (Document Object)

This object corresponds to an < input > tag in the document. The type of the input field is set by the type attribute and includes "text", "password", "checkbox", "radio", "submit", "reset", "file", "hidden", "image", and "button". Traditional models drew a distinction between < input > elements with different type attributes and called them by the type value (for example, Text , Password , or Radio). With the rise of the DOM, this distinction is no longer quite as clearly defined, but for historical reasons we list each type under its type attribute. The exception is "image," which has most of the properties of Button (in addition to Image under Internet Explorer). Access to the various instantiations of this object is achieved through standard DOM methods, or more commonly through the elements[] array of the Form in which the < input > is enclosed.

Properties

See Checkbox , Hidden , Password , Radio , or Text depending on type.

Methods

See Checkbox , Hidden , Password , Radio , or Text depending on type.

Support

The generic < input > element as defined in the DOM as HTMLInputElement is supported in Internet Explorer 4+, Mozilla/Netscape 6+, and DOM1. However, support for specific types of < input >s was available in much earlier versions.

ins, HTMLModElement (Document Object)

This object corresponds to an < ins > (insertion modification) element in the document. Access to this object is achieved through standard DOM methods such as document.getElementById() .

Properties

This object has the following properties, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This element has the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

Notes

This object is the same as the one associated with the < del > tag as under the DOM both are HTMLModElement objects. We break them out separately as developers familiar with (X)HTML will consider them to have different meanings.

isIndex, HTMLIsIndexElement (Document Object)

This object corresponds to the deprecated HTML tag < isindex >. While it is not used often, it is defined by the DOM and accessible via common DOM methods.

Properties

This object has the following properties, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This object only has the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

Notes

The < isindex > tag is deprecated and rarely used and this object is only presented for completeness since it is documented both in IE s DHTML syntax and the DOM1 specification.

java (Browser Object)

See Packages .

kbd, HTMLElement (Document Object)

This object corresponds to a < kbd > (keyboard input) tag in the document. It has the properties and methods listed in the Generic HTML Element object found at the beginning of this section.

Properties

This object only supports the properties listed in the Generic HTML Element object found at the beginning of this section.

Methods

This object only supports the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

Notes

You may see browsers like Mozilla identify this object as an HTMLSpanElement though no such object exists in the DOM. The correct indication is HTMLElement , though Internet Explorer just indicates it as a generic object.

label, HTMLLabelElement (Document Object)

This object corresponds to a < label > (form field label) tag in the document. Access to this object is achieved through standard DOM methods such as document.getElementById() .

Properties

This object has the following properties, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This object only has the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

Notes

Despite being a tag found within a < form > it will not be represented in the elements[] array of a form object.

Layer (Proprietary Document Object)

Layer objects correspond to < layer > or < ilayer > tags and are supported in Netscape 4 only. This object was deprecated in favor of the standard < div > tag in conjunction with CSS absolute positioning, which provides very similar functionality.

Properties

Methods

Support

This object is only supported in Netscape 4.

Notes

Though very proprietary, this object is still occasionally used by developers of DHTML-style navigation systems and other effects to ensure complete backward compatability. See Chapters 15 and 16 for examples of this object s use.

legend, HTMLLegendElement (Document Object)

This object corresponds to a < legend > (fieldset caption) tag in the document. Access to this object is achieved through standard DOM methods.

Properties

This object has the following properties, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This object only has the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

lI, HTMLLIElement (Document Object)

This object corresponds to a < li > (list item) tag in the document. Access to this object is achieved through standard DOM methods such as document.getElementById() or by traversal from a parent HTMLOListElement of HTMLUListElement object.

Properties

This object has the following properties, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This object only has the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

link, HTMLLinkElement (Document Object)

This object corresponds to a < link > (externally linked file) tag in the document. Access to this object is achieved through standard DOM methods such as document.getElementById() . For information about the traditional Link object that corresponds to a < a href="" >< /a >, see the entry for a near the start of the section.

Properties

This object has the following properties, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This object only has the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

Location (Browser Object)

The Location object provides access to the current document s URL and component in a convenient fashion. Assigning a string to a Location object causes the browser to automatically parse the string as a URL, update the object s properties, and set the string itself as the href property of the object.

Properties

Methods

Support

Supported in IE3+ (JScript 1.0+), N2+ (JavaScript 1.0+), MOZ.

Notes

While most browsers will automatically reflect changes to any property of this object, it is safer to assign the new, complete URL to the href attribute or the object itself to ensure that changes are properly reflected by the browser.

map, HTMLMapElement (Document Object)

This object corresponds to a < map > (client-side image map) tag in the document. Access to this object is achieved through standard DOM methods like document.getElementById() .

Properties

Methods

This object only has the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

marquee (Proprietary Document Object)

This object corresponds to a (nonstandard) < marquee > element in the document. Access to this object is generally via document.all[] since it is generally proprietary to Internet Explorer; however, it may be accessible through standard DOM methods like document.getElementById() . See MSDN documentation for full details.

Properties

This object has the following properties, in addition to those IE-specific properties in the Generic HTML Element object found at the beginning of this section:

Support

This object has the following properties, in addition to those IE-specific properties in the Generic HTML Element object found at the beginning of this section:

Support

Supported in Internet Explorer 4+.

Notes

Other browsers such as Mozilla or Opera may have limited support for the < marquee > tag but it is incomplete and scripting is generally not defined for the tag in these browsers.

Math (Built-in Object)

The Math object provides constants and methods that permit more advanced mathematical calculations than JavaScript s native arithmetic operators. All properties and methods of this object are static (class properties), so they are accessed through Math itself rather than an object instance.

Properties

Methods

Support

IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1

Notes

All trigonometric methods of Math treat values as radians, so you need to multiple any degree values by Math.PI/180 before passing them to one of these functions.

If the argument to one of Math s methods cannot be converted to a number, NaN is generally returned.

All the properties of the Math object are static and read-only.

All the methods of the Math object are static.

menu, HTMLMenuElement (Document Object)

This object corresponds to a < menu > (menu list) tag in the document. Access to this object is achieved through standard DOM methods.

Properties

This object has the following property, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This object only has the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

meta, HTMLMetaElement (Document Object)

This object corresponds to a < meta > tag in the document. Access to this object is achieved through standard DOM methods; often developers will use document.getElementsByTagName() to process multiple < meta > tags.

Properties

This object has the following properties, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This object only has the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

mimeType (Proprietary Browser Object)

Instances of mimeType objects are accessed through the array navigator.mimeTypes[] or through a Plugin object. They provide basic information regarding the MIME types the browser and its plug-ins can handle as well as on what types and filename suffixes are associated with each Plugin .

Examination of the navigator.mimeTypes[] array permits the programmer to determine whether a particular MIME type is supported and, if so, to extract information about the Plugin that handles it. Examination of a Plugin object permits the programmer to extract information about the plug-in as well as determine what MIME types it is currently configured to handle.

Properties

Methods

None.

Support

Netscape 3+ (JavaScript 1.1+).

Notes

Verifying the existence of a particular MIME type in the mimeTypes[] array is not a guarantee that the browser can handle the data; you also need to check the mimeType object s enabledPlugin property.

namespace (Proprietary Browser Object)

The namespace object allows you to import a DHTML Element Behavior (custom tag) dynamically, that is, during or after the page load. Its capabilities are outside of the scope of this book, but its methods are fairly straightforward. See Microsoft documentation for details on this rarely used proprietary object.

Support

Internet Explorer 5.5+ in Windows.

Navigator (Browser Object)

The Navigator object makes information about the client browser available to JavaScript. This object is most commonly used for browser detection, but also contains a wealth of detail about the user s configuration, language of preference, and operating system. Although the Navigator object was originally implemented in Netscape Navigator (hence the name), it is supported by most major browsers and has become the de facto standard for accessing configuration information. The entire Navigator object is read-only.

Properties

Methods

Support

Supported in most major browsers, including IE3+, N2+, MOZ.

netscape (Proprietary Browser Object)

See Packages .

noBR (Proprietary Document Object)

This object corresponds to a (nonstandard) < nobr > (text rendered without linebreaks) tag in the document. Access to this object is often performed via document.all[] , though it should be accessible in most browsers through standard DOM methods as well.

Properties

This object only supports the properties listed in the Generic HTML Element object found at the beginning of this section.

Methods

This object only supports the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in IE4+, MOZ.

Notes

You may see browsers like Mozilla or Opera identify this object as an HTMLSpanElement or even HTMLNobrElement though no such object exists in the DOM. The correct indication is HTMLElement , though Internet Explorer just indicates it as a generic object.

noFrames, HTMLElement (Document Object)

This object corresponds to a < noframes > (content for agents without frame support) tag in the document. It is accessed using standard DOM methods.

Properties

This object only supports the properties listed in the Generic HTML Element object found at the beginning of this section.

Methods

This object only supports the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

Notes

You may see browsers like Mozilla identify this object as an HTMLDivElement for some reason. The correct indication is HTMLElement , though Internet Explorer just indicates it as a generic object.

noScript, HTMLElement (Document Object)

This document object corresponds to a < noscript > (content for browsers that do not support scripting) element in the document. It is accessed using standard DOM methods like document.getElementById() .

Properties

This object only supports the properties listed in the Generic HTML Element object found at the beginning of this section.

Methods

This object only supports the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

Notes

You may see browsers like Mozilla identify this object as an HTMLDivElement for some reason. The correct indication is HTMLElement , though Internet Explorer just indicates it as a generic object.

Number (Built-in Object)

Number is the container object for the primitive number data type. The primary use of this object is accessing its methods for number formatting and using its static (class) properties, which define useful numeric constants.

Constructor

var instanceName = new Number( initialValue );

where initialValue is a number or a string that will be converted to a number. Omitting initialValue creates a Number with value zero.

Properties

Methods

Support

Supported in IE3+ (JScript 1.0+), MOZ, N3+ (JavaScript 1.1+), ECMAScript Edition 1.

Notes

To use Number methods on number literals, use a space between the literal and the dot operator, for example, "3.14159265 .toExponential()" .

All Number constants are static and read-only.

Object (Built-in Object)

Object is the basic object from which all other objects are derived. It defines methods common to all objects that are often overridden to provide functionality specific to each object type. For example, the Array object provides a toString() method that functions as one would expect an array s toString() method to behave.This object also permits the creation of user-defined objects and instances are quite often used as associative arrays.

Constructor

var instanceName = new Object();

This statement creates a new (generic) object.

Properties

Methods

Support

Supported in IE4+ (JScript 3.0+), MOZ, N2+ (JavaScript 1.0+), ECMAScript Edition 1.

object, HTMLObjectElement (Document Object)

This object corresponds to an < object > (embedded object) element in the document. Access to this object is achieved through standard DOM methods like document.getElementById() .

Properties

This object has the following properties, in addition to those in the Generic HTML Element object found at the beginning of this section. It will also have any properties exposed by the embedded object (for example, public java class variables).

Methods

This element has the methods listed in the Generic HTML Element object found at the beginning of this section. It will also have any methods exposed by the embedded object.

Support

Supported in IE4+, MOZ/N6+, DOM1.

ol, HTMLOListElement (Document Object)

This object corresponds to an < ol > (ordered list) tag in the document. Access to these objects is achieved through standard DOM methods.

Properties

This object has the following properties, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This element only has the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

optGroup, HTMLOptGroupElement (Document Object)

This object corresponds to an < optgroup > (option grouping within a < select >) tag in the document. Access to this object is achieved through standard DOM methods.

Properties

This object has the following properties, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This element only has the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in IE6+, MOZ/N6+, DOM1.

option, HTMLOptionElement (Document Object)

This object corresponds to an < option > element in the document. Such elements are found enclosed by < select > form fields. Access to this object is achieved through standard DOM methods (for example, document.getElementById() ) or through the options[] array of the Select object in which

it is enclosed.

Constructor

var instanceName = new Option( text [, value ]);

Creates a new option element that can then be added to the options[] array of the enclosing select . This method of creating option s is deprecated and you should use standard DOM methods instead.

Properties

This object has the following properties, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This object only has the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in IE3+, N2+, MOZ, DOM1.

p, HTMLParagraphElement (Document Object)

This document object corresponds to a < p > (paragraph) tag in the document. Access to this object is achieved through standard DOM methods such as document.getElementById() .

Properties

This object has the following property, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This object only has the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in IE4+, MOZ/N6+, DOM1.

Packages (Proprietary Browser Object)

Netscape provides access to the public interfaces of Java classes through the Packages object. Commonly used classes ( java , netscape , and sun ) are available through this object and also as top-level objects themselves. To access a Java class installed on the client machine, access the fully qualified Java class name through this object. For example, to instantiate a Java Frame object, you would use

var myFrame = new Packages.java.awt.Frame();

See a reference on Java or Netscape s Java and LiveConnect documentation for more information.

Properties

Every Java class and property defined in the client s Java implementation is available as a property of this object. The most commonly used classes are found in the java , netscape , and sun packages. Classes are accessed using their fully qualified class name as a property, for example, Packages.java.awt.Frame .

Methods

Every public method of every Java class is available by accessing its fully qualified name.

Support

Supported in MOZ, N3+ (JavaScript 1.1+).

page (Proprietary Document Object)

This Internet Explorer “specific object represents an @page rule within a styleSheet that is used for printer output.

Properties

Methods

None

Support

Supported in Internet Explorer 5.5+.

Notes

See MSDN for further details on this object.

param, HTMLParamElement (Document Object)

This object corresponds to an occurrence of a < param > element (initial parameter to an embedded object) in the document. This object can be accessed using standard DOM methods like document.getElementById() .

Properties

This object has the following properties, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This object only has the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

Password, HTMLInputElement (Document Object)

This object corresponds to an occurrence of a password input field (< input type="password" >) in the document. This object can be accessed using standard DOM methods or through the Form element that contains it (via the elements[] array or by name ). The structure of this object is nearly identical to the structure of the Text object, so see the reference for Text for details.

Properties

Same as Text object.

Methods

Same as Text object.

Support

Supported in Internet Explorer 3+, Mozilla, Netscape 2+, DOM1.

plainText (Deprecated Proprietary Document Object)

This object corresponds to the occurrence of the deprecated < plaintext > tag in a document. Internet Explorer still supports this tag and its associated object but Microsoft documentation indicates it is deprecated and < pre > should be used instead.

Plugin (Proprietary Browser Object)

Each Plugin object corresponds to a plug-in installed in the browser. Such objects are available through the enabledPlugin property of mimeType objects or through the navigator.plugins[] array. Each Plugin provides information about the plug-in, such as its description, the MIME types it handles, and its name. Each Plugin , in addition to having the properties defined here, is an array of mimeType objects representing the MIME types that the plug-in handles for the browser. This object is used to determine whether the browser supports a specific plug-in and version.

Access to page content handled by a plug-in (for example, an < embed > element), including properties made available via LiveConnect, is carried out using the document.embeds[] array or by fetching a reference to the object using standard DOM techniques.

Although Internet Explorer provides plug-in support and LiveConnect functionality, Plugin objects are only available in Mozilla and Netscape browsers.

Properties

Methods

None.

Support

Mozilla, Netscape 3+ (JavaScript 1.1+).

Notes

In order to ensure that a particular plug-in is handling a particular MIME type, it is not sufficient to check for the existence of the Plugin object in which you are interested. You must also check to ensure that the Plugin is currently handling the appropriate MIME type, for example:

if (navigator.plugins['Some Player'] && navigator.plugins['Some Player']['video/mpeg'])

See also the plugins[] property of the Navigator object.

popup (Proprietary Browser Object)

A popup is a stripped-down Window object created using IE s createPopup() method. Pop-up windows are created initially hidden and without content; the programmer is responsible for writing content to it and rendering it visible.

Properties

Methods

Support

Supported in IE5.5+.

Notes

These objects are often referred to as chromeless windows.

pre, HTMLPreElement (Document Object)

This object corresponds to a < pre > (preformatted text) tag in the document. Access to this object is achieved through standard DOM methods such as document.getElementById() .

Properties

This object has the following property, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This object only has the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Netscape 6+, DOM1.

q, HTMLQuoteElement (Document Object)

This object corresponds to a < q > (quote) element in the document. Access to this object is achieved through standard DOM methods such as document.getElementById() .

Properties

This object has the following property, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This object only has the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

Notes

Mozilla and Opera 7.5+ correctly identify this object as HTMLQuoteElement while Internet Explorer reports it as a generic object. Opera 7.5+ also recognizes the ad hoc < bq > syntax as HTMLQuoteElement .

Radio, HTMLInputElement (Document Object)

This object corresponds to an < input type="radio" > form input field. Access to this object is achieved through standard DOM methods or through the enclosing Form (via its elements[] array or by name ). The most common way of accessing this object is through the Form element because many radio elements have the same name attribute.

Properties

This object has the following property, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This object supports the methods listed in the Generic HTML Element object found at the beginning of this section as well as the following:

Support

Internet Explorer 3+, Mozilla, Netscape 2+, DOM1.

RegExp (Built-in Object)

Instances of RegExp objects hold regular expression patterns and provide the properties and methods that enable their use on strings. In addition, each window has a RegExp object that provides static (class) properties giving information about the most recent match that was executed. These properties are dynamically scoped.

Constructor

var instanceName = new RegExp( expr [ , flags ]);

where expr is a string containing a regular expression (for example, "abc.*") and flags is an optional string denoting the flags for the expression (for example, "gi").

Properties

Methods

Support

Supported in IE4+ (JScript 3.0+), MOZ, N4+ (JavaScript 1.2+), ECMAScript Edition 3.

Notes

For a list of special regular expression characters, see Appendix A.

Reset, HTMLInputElement (Document Object)

This object corresponds to an < input type="reset" > form input field. Access to this object is achieved through standard DOM methods or through the enclosing Form (via its elements[] array or by name ). Note that all Form s have a reset() method that can be directly invoked regardless of the occurrence of an explicit Reset button.

Properties

This object has the following properties, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This object supports the methods listed in the Generic HTML Element object found at the beginning of this section in conjunction to the following:

Support

Internet Explorer 3+, MOZ, N2+, DOM1.

rt (Proprietary Document Object)

This Internet Explorer object corresponds to a (nonstandard) < rt > tag that is used within a < ruby > tag to create a pronounciation guide or add an annotation to some text. It is commonly used in languages like Japanese. Access to this object is often performed via document.all[] , though it should be accessible through standard DOM methods as well.

Properties

This object only supports a selection of the Internet Explorer “specific properties listed in the Generic HTML Element object found at the beginning of this section.

Methods

This object only supports a selection of the Internet Explorer “specific methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in IE5.5+

Notes

See the MSDN site for details on the < rt > tag and the use of the associated JavaScript object.

ruby (Proprietary Document Object)

This Internet Explorer object corresponds to a (nonstandard) < ruby > tag that is used when creating a pronounciation guide or annotation to some text. It is commonly used in languages like Japanese. Access to this object is often performed via document.all[] , though it should be accessible through standard DOM methods as well.

Properties

This object only supports a selection of the Internet Explorer “specific properties listed in the Generic HTML Element object found at the beginning of this section.

Methods

This object only supports a selection of the Internet Explorer “specific methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in IE5.5+

Notes

See the MSDN site for details on the < ruby > tag and the use of the associated JavaScript object.

rule, CSSrule (Document object)

Instances of rule objects correspond to CSS rules found in the styleSheet object, and are accessed through the cssRules[] or rules[] collections of that object. An easy way to manipulate rule objects is to manipulate the appropriate portion of their style property.

Properties

Methods

None.

Notes

The official DOM2 name for this object is cssRule . DOM2 defines other, unimplemented features for certain kinds of rule s.

runtimeStyle (Proprietary Document object)

A Style object that has precedence over the normal Style object for the element. Because the normal Style object reflects only inline style set with the style attribute, it does not reflect style set by default or through externally linked style sheets. This object does , and permits you to modify style values without the changes being reflected into the element s inline style or styleSheet objects that might exist. Equivalent functionality in Mozilla is provided by the computedStyle object.

Support

Internet Explorer 5+.

samp, HTMLElement (Document Object)

This object corresponds to a < samp > (code sample) tag in the document. It is accessed via standard DOM methods like document.getElementById() .

Properties

This object only supports the properties listed in the Generic HTML Element object found at the beginning of this section.

Methods

This object only supports the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

Notes

You may see browsers like Mozilla identify this object as an HTMLSpanElement , though no such object exists in the DOM. The correct indication is HTMLElement , though Internet Explorer just indicates it as a generic object.

screen (Browser object)

The screen object makes information about the client s display capabilities available to JavaScript.

Properties

Methods

None.

Support

Supported in IE4+, Mozilla, N4+.

script, HTMLScriptElement (Document Object)

This object corresponds to a < script > tag in the document. Access to this object is achieved through standard DOM methods such as document.getElementById() or in Internet Explorer through document.scripts[] . While examination or modification of source code is easily carried out by examining the text nodes enclosed by this object (DOM) or its innerText property (IE), self-modifying code can lead to anomalous behavior.

Properties

This object has the following properties, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This object supports only the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

select, HTMLSelectElement (Document Object)

This object corresponds to a < select > tag in the document. Access to this object is achieved through standard DOM methods such as document.getElementById() or through the Form in which it is contained, often via its elements[] array or by name .

Properties

This object has the following properties, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This object has the methods listed in the Generic HTML Element object found at the beginning of this section as well as the following:

Support

Supported in Internet Explorer 3+, Mozilla, Netscape 2+, DOM1.

selection (Proprietary Browser Object)

This Internet Explorer “specific object represents the active selection, as defined by the user highlighting a block of the document. Selections can also be created by script by invoking the select() method of a TextRange object.

Properties

Methods

Support

Supported in IE4+.

small, HTMLElement (Document Object)

This object corresponds to a < small > (small text) text in the document. It is accessed via standard DOM methods.

Properties

This object only supports the properties listed in the Generic HTML Element object found at the beginning of this section.

Methods

This object only supports the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

span, HTMLElement (Document Object)

This object corresponds to a < span > (inline container) tag in the document. Access to this object is achieved through standard DOM methods such as document.getElementById() .

Properties

This object has the following properties, in addition to those in the Generic HTML Elemen t object found at the beginning of this section:

Methods

This object has the following method, in addition to those in the Generic HTML Element object found at the beginning of this section:

Support

Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

strike, HTMLElement (Document Object)

This object corresponds to a < strike > (struck-through text) tag in the document. Access to this object is achieved through standard DOM methods such as document.getElementById() .

Properties

This object only supports the properties listed in the Generic HTML Element object found at the beginning of this section.

Methods

This object only supports the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

Notes

You may see browsers like Mozilla identify this object as an HTMLSpanElement , though no such object exists in the DOM. The correct indication is HTMLElement , though Internet Explorer just indicates it as a generic object.

String (Built-in Object)

String is the container object for the primitive string data type. It supplies methods for the manipulation of strings in addition to those that create traditional HTML markup from plain text. When manipulating strings, remember that like all JavaScript indices, the enumeration of character positions begins with zero.

Constructor

var instanceName = new String( initialValue );

where initialValue is a string. Omitting initialValue creates a String where value is the empty string ("").

Properties

Methods

Support

Supported in IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), ECMAScript Edition 1.

Notes

This object does not operate on values in place. That is, when manipulating a String with one of its methods, the method returns the result of the operation. It does not change the value of the String that it was invoked as a method of. You can, of course, use self-assignment to this effect ”for example,

var mystring = mystring.toUpperCase()

The String methods do not produce XHTML style markup.

strong, HTMLElement (Document Object)

This object corresponds to a < strong > (strong emphasis) tag in the document. Access to this object is achieved through standard DOM methods such as document.getElementById() .

Properties

This object only supports the properties listed in the Generic HTML Element object found at the beginning of this section.

Methods

This object only supports the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

Notes

You may see browsers like Mozilla identify this object as an HTMLSpanElement though no such object exists in the DOM. The correct indication is HTMLElement , though Internet Explorer just indicates it as a generic object.

Style (Document Object)

The Style object permits the examination and manipulation of an element s inline style (those properties defined with the style (X)HTML attribute). The most common way it is accessed is as a property of the Element object, for example as myElement.style . If you need to manipulate the appearance of an object on screen, this is the primary object that is used.

This object does not provide access to styles defined in < style > or linked style sheets defined by < link >. To access such style rules, use the styleSheet object found in document.styleSheets[] . You can also access a < style > element directly by fetching it using standard DOM methods like document.getElementById() .

Properties

The properties of the Style object that correspond to CSS attributes are listed in the Table B-2, along with their support. The following table combines both standard CSS properties with Microsoft documentation. Be aware that most of the properties contain strings (with the exception of certain Microsoft-specific properties such as those that are pixel - and pos -related, which contain integers). It is always a good idea to set these properties to strings (and not numbers) and to specify units of measure (for example, "100px" or "20em") where appropriate.

Table B-2: Properties of the Style Object

Style Property

Corresponding DOM/JS Property

Support

Description

azimuth

azimuth

N7+/MOZ

Controls the direction the spoken voice appears to be coming from when a screen reader is in use.

background

background

IE4+, N6+/MOZ

Sets or retrieves (up to) the five separate background properties of the object.

background-attachment

backgroundAttachment

IE4+, N6+/MOZ

Sets or retrieves how the background image is attached to the object within the document.

background-color

backgroundColor

IE4+, N4+, MOZ

Sets or retrieves the color behind the content of the object.

background-image

backgroundImage

IE4+, N4+, MOZ

Sets or retrieves the background image of the object.

background-position

backgroundPosition

IE4+, N6+/MOZ

Sets or retrieves the position of the background of the object.

background-position-x

backgroundPositionX

IE4+

Sets or retrieves the x coordinate of the backgroundPosition property.

background-position-y

backgroundPositionY

IE4+

Sets or retrieves the y coordinate of the backgroundPosition property.

background-repeat

backgroundRepeat

IE4+, N6+/MOZ

Sets or retrieves how the backgroundImage property of the object is tiled.

behavior

behavior

IE5+

Sets or retrieves the location of the DHTML Behaviors.

border

border

IE4+, N6+/MOZ

Sets or retrieves the properties to draw around the object.

border-bottom

borderBottom

IE4+, N6+/MOZ

Sets or retrieves the properties of the bottom border of the object.

border-bottom-color

borderBottomColor

IE4+, N6+/MOZ

Sets or retrieves the color of the bottom border of the object.

border-bottom-style

borderBottomStyle

IE4+, N6+/MOZ

Sets or retrieves the style of the bottom border of the object.

border-bottom-width

borderBottomWidth

IE4+, N4+

Sets or retrieves the width of the bottom border of the object.

border-collapse

borderCollapse

N6+/MOZ

Sets or retrieves a value that indicates whether the row and cell borders of a table are joined in a single border or detached as in standard HTML.

border-color

borderColor

IE4+, N4+, MOZ

Sets or retrieves the border color of the object.

border-left

borderLeft

IE4+, N6+/MOZ

Sets or retrieves the properties of the left border of the object.

border-left-color

borderLeftColor

IE4+, N6+/MOZ

Sets or retrieves the color of the left border of the object.

border-left-style

borderLeftStyle

IE4+, N6+/MOZ

Sets or retrieves the style of the left border of the object.

border-left-width

borderLeftWidth

IE4+, N4+, MOZ

Sets or retrieves the width of the left border of the object.

border-right

borderRight

IE4+, N6+/MOZ

Sets or retrieves the properties of the right border of the object.

border-right-color

borderRightColor

IE4+, N6+/MOZ

Sets or retrieves the color of the right border of the object.

border-right-style

borderRightStyle

IE4+, N6+/MOZ

Sets or retrieves the style of the right border of the object.

border-right-width

borderRightWidth

IE4+, N4+, MOZ

Sets or retrieves the width of the right border of the object.

border-spacing

borderSpacing

N6+/MOZ

Sets or retrieves the width of the spacing between table cells.

border-style

borderStyle

IE4+, N4+, MOZ

Sets or retrieves the style of the left, right, top, and bottom borders of the object.

border-top

borderTop

IE4+, N6+/MOZ

Sets or retrieves the properties of the top border of the object.

border-top-color

borderTopColor

IE4+, N6+/MOZ

Sets or retrieves the color of the top border of the object.

border-top-style

borderTopStyle

IE4+, N6+/MOZ

Sets or retrieves the style of the top border of the object.

border-top-width

borderTopWidth

IE4+, N4+, MOZ

Sets or retrieves the width of the top border of the object.

border-width

borderWidth

IE4+, N6+/MOZ

Sets or retrieves the width of the left, right, top, and bottom borders of the object.

bottom

bottom

IE5+, N6+/MOZ

Sets or retrieves the bottom position of the object in relation to the bottom of the next positioned object in the document hierarchy.

caption-side

captionSide

N6+/MOZ

Sets or retrieves the position of the table caption.

clear

clear

IE4+, N4+, MOZ

Sets or retrieves whether the object allows floating objects on its left side, right side, or both, so that the next text displays past the floating objects.

clip

clip

IE4+, N6+/MOZ

Sets or retrieves which part of a positioned object is visible.

color

color

IE4+, N4+, MOZ

Sets or retrieves the color of the text of the object.

rloat

cssFloat

N6+/MOZ

Sets or retrieves the content wrapping behavior of the element.

cue

cue

N7+/MOZ

Controls whether a delimiting tone should be played before and after reading the text when a screen reader is in use.

cue-after

cueAfter

N7+/MOZ

Controls whether a delimiting tone should be played after reading the text when a screen reader is in use.

cue-before

cueBefore

N7+/MOZ

Controls whether a delimiting tone should be played before reading the text when a screen reader is in use.

cursor

cursor

IE4+, N6+/MOZ

Sets or retrieves the type of cursor to display as the mouse pointer moves over the object.

direction

direction

IE5+, N6+/MOZ

Sets or retrieves the reading order of the object.

display

display

IE4+, N4+, MOZ

Sets or retrieves whether the object is rendered.

elevation

elevation

N7+/MOZ

Controls where elevation (above or below) of the spoken voice when a screen reader is employed.

empty-cells

emptyCells

N6+/MOZ

Sets or retrieves whether table cells without content are displayed.

font

font

IE4+, N6+/MOZ

Sets or retrieves up to the six separate font properties of the object.

font-family

fontFamily

IE4+, N4+, MOZ

Sets or retrieves the name of the font used for text in the object.

font-size

fontSize

IE4+, N4+, MOZ

Sets or retrieves the size of the font used for text in the object.

font-size-adjust

fontSizeAdjust

N6+/MOZ

Sets or retrieves size adjustment of the font.

font-stretch

fontStretch

N6+/MOZ

Sets or retrieves how much the characters are stretched or compressed.

font-style

fontStyle

IE4+, N4+, MOZ

Sets or retrieves the font style of the object as italic, normal, or oblique .

font-variant

fontVariant

IE4+, N6+/MOZ

Sets or retrieves whether the text of the object is in small capital letters.

font-weight

fontWeight

IE4+, N4+, MOZ

Sets or retrieves the weight of the font of the object.

height

height

IE4+, N6+/MOZ

Sets or retrieves the height of the object.

ime-mode

imeMode

IE5+

Controls the state of the Input Method Editor for insertion of eastern character sets (Chinese/Japanese/Korean).

layout-flow

layoutFlow

IE5.5+

Sets or retrieves the direction and flow of the content in the object.

layout-grid

layoutGrid

IE5+

Sets or retrieves the composite document grid properties that specify the layout of text characters.

layout-grid-char

layoutGridChar

IE5+

Sets or retrieves the size of the character grid used for rendering the text content of an element.

layout-grid-line

layoutGridLine

IE5+

Sets or retrieves the gridline value used for rendering the text content of an element.

layout-grid-mode

layoutGridMode

IE5+

Sets or retrieves whether the text layout grid uses two dimensions.

layout-grid-type

layoutGridType

IE5+

Sets or retrieves the type of grid used for rendering the text content of an element.

left

left

IE4+, N6+/MOZ

Sets or retrieves the position of the object relative to the left edge of the next-positioned object in the document hierarchy.

letter-spacing

letterSpacing

IE4+, N6+/MOZ

Sets or retrieves the amount of additional space between letters in the object.

line-break

lineBreak

IE5+

Sets or retrieves line-breaking rules for Japanese text.

line-height

lineHeight

IE4+, N4+, MOZ

Sets or retrieves the distance between lines in the object.

list-style

listStyle

IE4+, N6+/MOZ

Sets or retrieves up to three separate listStyle properties of the object.

list-style-image

listStyleImage

IE4+, N6+/MOZ

Sets or retrieves which image to use as a list-item marker for the object.

list-style-position

listStylePosition

IE4+, N6+/MOZ

Sets or retrieves how the list-item marker is drawn relative to the content of the object.

list-style-type

listStyleType

IE4+, N4+, MOZ

Sets or retrieves the predefined type of the line-item marker for the object.

margin

margin

IE4+, N6+/MOZ

Sets or retrieves the width of the top, right, bottom, and left margins of the object.

margin-bottom

marginBottom

IE4+, N4+, MOZ

Sets or retrieves the height of the bottom margin of the object.

margin-left

marginLeft

IE4+, N4+, MOZ

Sets or retrieves the width of the left margin of the object.

margin-right

marginRight

IE4+, N4+, MOZ

Sets or retrieves the width of the right margin of the object.

margin-top

marginTop

IE4+, N4+, MOZ

Sets or retrieves the height of the top margin of the object.

max-height

maxHeight

N6+/MOZ

Sets or retrieves the maximum height of the element.

max-width

maxWidth

N6+/MOZ

Sets or retrieves the maximum width of the element.

min-height

minHeight

IE6+, N6+/MOZ

Sets or retrieves the minimum height for an element.

min-width

minWidth

N6+/MOZ

Sets or retrieves the minimum width for an element.

orphans

orphans

N6+/MOZ

Sets or retrieves the minimum number of lines of a paragraph to display at the bottom of a page when performing page wrapping.

outline

outline

N6+/MOZ

Sets or retrieves up to the three outline properties.

outline-color

outlineColor

N6+/MOZ

Sets or retrieves the color of the outline around the element.

outline-style

outlineStyle

N6+/MOZ

Sets or retrieves the outline style of the outline around the element.

outline-width

outlineWidth

N6+/MOZ

Sets or retrieves the width of the outline around the element.

overflow

overflow

IE4+, N6+/MOZ

Sets or retrieves a value indicating how to manage the content of the object when the content exceeds the height or width of the object.

overflow-x

overflowX

IE5+

Sets or retrieves how to manage the content of the object when the content exceeds the width of the object.

overflow-y

overflowY

IE5+

Sets or retrieves how to manage the content of the object when the content exceeds the height of the object.

padding

padding

IE4+, N6+/MOZ

Sets or retrieves the amount of space to insert between the object and its margin or, if there is a border, between the object and its border.

padding-bottom

paddingBottom

IE4+, N4+, MOZ

Sets or retrieves the amount of space to insert between the bottom border of the object and the content.

padding-left

paddingLeft

IE4+, N4+, MOZ

Sets or retrieves the amount of space to insert between the left border of the object and the content.

padding-right

paddingRight

IE4+, N4+, MOZ

Sets or retrieves the amount of space to insert between the right border of the object and the content.

padding-top

paddingTop

IE4+, N4+, MOZ

Sets or retrieves the amount of space to insert between the top border of the object and the content.

@@page

page

N6+/MOZ

Sets or retrieves the page orientation for printing.

page-break-after

pageBreakAfter

IE4+, N6+/MOZ

Sets or retrieves a value indicating whether a page break can occur after the object.

page-break-before

pageBreakBefore

IE4+, N6+/MOZ

Sets or retrieves a string indicating whether a page can occur before the object.

page-break-inside

pageBreakInside

N6+/MOZ

Sets or retrieves a string indicating whether a page break can occur inside the object.

pause

pause

N6+/MOZ

Sets or retrieves values controlling whether a screen reader will pause before and after reading the element.

pause-after

pauseAfter

N6+/MOZ

Sets or retrieves values controlling whether a screen reader will pause after reading the element.

pause-before

pauseBefore

N6+/MOZ

Sets or retrieves values controlling whether a screen reader will pause before reading the element.

pitch

pitch

N6+/MOZ

Sets or retrieves the voice pitch to be used when a screen reader reads the element.

pitch-range

pitchRange

N6+/MOZ

Sets or retrieves the average voice pitch to be used when a screen reader reads the element.

pitch-during

pitchDuring

N6+/MOZ

Sets or retrieves the voice pitch to be used when a screen reader reads the element.

n/a

pixelBottom

IE4+

Sets or retrieves the bottom position of the object.

n/a

pixelHeight

IE4+

Sets or retrieves the height of the object.

n/a

pixelLeft

IE4+

Sets or retrieves the left position of the object.

n/a

pixelRight

IE4+

Sets or retrieves the right position of the object.

n/a

pixelTop

IE4+

Sets or retrieves the top position of the object.

n/a

pixelWidth

IE4+

Sets or retrieves the width of the object.

n/a

posBottom

IE4+

Sets or retrieves the bottom position of the object in the units specified by the bottom attribute.

n/a

posHeight

IE4+

Sets or retrieves the height of the object in the units specified by the height attribute.

position

position

IE4+, N6+/MOZ

Sets or retrieves the type of positioning used for the object.

n/a

posLeft

IE4+

Sets or retrieves the left position of the object in the units specified by the left attribute.

n/a

posRight

IE4+

Sets or retrieves the right position of the object in the units specified by the right attribute.

n/a

posTop

IE4+

Sets or retrieves the top position of the object in the units specified by the top attribute.

n/a

posWidth

IE4+

Sets or retrieves the width of the object in the units specified by the width attribute.

quotes

quotes

N6+/MOZ

Sets or retrieves the characters to replace quotation marks with (for example, "' '")

richness

richness

N6+/MOZ

Controls the "brightness" of the speaking voice for screen readers.

right

right

IE5+, N6+/MOZ

Sets or retrieves the position of the object relative to the right edge of the next positioned object in the document hierarchy.

ruby-align

rubyAlign

IE5+

Sets or retrieves the position of the ruby text specified by the rt object.

ruby-overhang

rubyOverhang

IE5+

Sets or retrieves the position of the ruby text specified by the rt object.

ruby-position

rubyPosition

IE5+

Sets or retrieves the position of the ruby text specified by the rt object.

scrollbar-3dlight-color

scrollbar3dLightColor

IE5.5+

Sets or retrieves the color of the top and left edges of the scroll box and scroll arrows of a scroll bar.

scrollbar-arrow-color

scrollbarArrowColor

IE5.5+

Sets or retrieves the color of the arrow elements of a scroll arrow.

scrollbar-base-color

scrollbarBaseColor

IE5.5+

Sets or retrieves the color of the main elements of a scroll bar, which include the scroll box, track, and scroll arrows.

scrollbar-darkshadow-color

scrollbarDarkShadowColor

IE5.5+

Sets or retrieves the color of the gutter of a scroll bar.

scrollbar-face-color

scrollbarFaceColor

IE5.5+

Sets or retrieves the color of the scroll box and scroll arrows of a scroll bar.

scrollbar-highlight-color

scrollbarHighlightColor

IE5.5+

Sets or retrieves the color of the top and left edges of the scroll box and scroll arrows of a scroll bar.

scrollbar-shadow-color

scrollbarShadowColor

IE5.5+

Sets or retrieves the color of the bottom and right edges of the scroll box and scroll arrows of a scroll bar.

scrollbar-track-color

scrollbarTrackColor

IE5.5+

Sets or retrieves the color of the track element of a scroll bar.

size

size

N6+/MOZ

Sets or retrieves the dimensions of the page for printing.

speak

speak

N7+/MOZ

Specifies the manner in which text will be rendered aurally when a screen reader is in use.

speak-header

speakHeader

N7+/MOZ

Controls whether table headers will be spoken when a screen reader is in use.

speak-numeral

speakNumeral

N7+/MOZ

Controls whether numbers will be read as a series of digits or as a number when a screen reader is in use.

speak-punctuation

speakPunctuation

N7+/MOZ

Controls whether punctuation will be spoken literally when a screen reader is in use.

speech-rate

speechRate

N7+/MOZ

Controls how fast text will be spoken when a screen reader is in use.

stress

stress

N7+/MOZ

Controls the stress of the spoken voice when a screen reader is in use.

float

styleFloat

IE4+

Sets or retrieves on which side of the object the text will flow.

table-layout

tableLayout

IE5+, N6+/MOZ

Sets or retrieves a string that indicates whether the table layout is fixed.

text-align

textAlign

IE4+, N4+, MOZ

Sets or retrieves whether the text in the object is left-aligned, right-aligned, centered, or justified.

text-align-last

textAlignLast

IE5.5+

Sets or retrieves how to align the last line or only line of text in the object.

text-autospace

textAutospace

IE5+

Sets or retrieves the autospacing and narrow space width adjustment of text.

text-decoration

textDecoration

IE4+, N4+, MOZ

Sets or retrieves whether the text in the object has blink, line-through, overline, or underline decorations.

n/a

textDecorationBlink

IE4+

Sets or retrieves a Boolean value that indicates whether the object's textDecoration property has a value of "blink".

n/a

textDecorationLineThrough

IE4+

Sets or retrieves a Boolean value indicating whether the text in the object has a line drawn through it.

n/a

textDecorationNone

IE4+

Sets or retrieves the Boolean value indicating whether the textDecoration property for the object has been set to none.

n/a

textDecorationOverline

IE4+

Sets or retrieves a Boolean value indicating whether the text in the object has a line drawn over it.

n/a

textDecorationUnderline

IE4+

Sets or retrieves whether the text in the object is underlined .

text-indent

textIndent

IE4+, N4+, MOZ

Sets or retrieves the indentation of the first line of text in the object.

text-justify

textJustify

IE5+

Sets or retrieves the type of alignment used to justify text in the object.

text-kashida-space

textKashidaSpace

IE5.5+

Sets or retrieves the ratio of kashida expansion to whitespace expansion when justifying lines of text in the object.

text-overflow

textOverflow

IE6+

Sets or retrieves a value that indicates whether to render ellipses (...) to indicate text overflow.

text-transform

textTransform

IE4+, N4+, MOZ

Sets or retrieves the rendering of the text in the object.

text-underline-position

textUnderlinePosition

IE5.5+

Sets or retrieves the position of the underline decoration that is set through the textDecoration property of the object.

top

top

IE4+, N6+/MOZ

Sets or retrieves the position of the object relative to the top of the next-positioned object in the document hierarchy.

unicode-bidi

unicodeBidi

IE5+, N6+/MOZ

Sets or retrieves the level of embedding with respect to the bidirectional algorithm.

vertical-align

verticalAlign

IE4+, N6+/MOZ

Sets or retrieves the vertical alignment of the object.

visibility

visibility

IE4+, N6+/MOZ

Sets or retrieves whether the content of the object is displayed. Values are "collapse", "hidden", or "visible".

voice-family

voiceFamily

N7+/MOZ

Controls the type of voice that will speak the text when a screen reader is in use.

volume

volume

N7+/MOZ

Controls the volume at which text will be spoken when a screen reader is in use.

white-space

whiteSpace

IE4+, N4+, MOZ

Sets or retrieves a value that indicates whether lines are automatically broken inside the object.

widows

widows

N6+/MOZ

Sets or retrieves the minimum number of lines of a paragraph to display at the top of a page when performing page wrapping.

width

width

IE4+, N4+, MOZ

Sets or retrieves the width of the object.

word-break

wordBreak

IE5+

Sets or retrieves line-breaking behavior within words, particularly where multiple languages appear in the object.

word-spacing

wordSpacing

IE4+, N6+/MOZ

Sets or retrieves the amount of additional space between words in the object.

word-wrap

wordWrap

IE5.5+

Sets or retrieves whether to break words when the content exceeds the boundaries of its container.

writing-mode

writingMode

IE5.5+

Sets or retrieves the direction and flow of the content in the object.

z-index

zIndex

IE4+, N6+/MOZ

Sets or retrieves the stacking order of positioned objects.

zoom

zoom

IE5.5+

Sets or retrieves the magnification scale of the object.

Filters

Style objects in Internet Explorer also contain properties enabling you to control the behavior of any CSS filters (see Chapter 21) that might be applied to the object. See MSDN s reference for the Style object or MSDN's discussion of CSS Filters for complete details.

Methods

Support

Internet Explorer 4+, primitive support in Netscape 4, excellent support in Mozilla/Netscape 6+, DOM2, CSS1, CSS2.

style (Document Object)

This object corresponds to an occurrence of a < style > tag in the page. It is not the Style object that defines stylistic characteristics for each element. The proper way to manipulate the style sheets found on the page is through the array of styleSheet objects found in document.styleSheets[] . You can also access the styleSheet object corresponding to a < style > element using its sheet (Mozilla/Netscape 6+) or styleSheet (IE4+) property.

Access to < style > objects is carried out through normal DOM methods like document.getElementById() . Most of the properties found in objects corresponding to < style > elements are generic element properties.

Properties

This object has the following properties, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This element only supports the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

styleSheet (Document Object)

Each style sheet used in the document has a corresponding styleSheet object in the document.styleSheets[] collection (in load order). While < style > objects represent actual < style > elements in the page, styleSheet objects present the programmer with an interface with which the rules contained in each style sheet can be examined and manipulated in a regular fashion. All style sheets visible in the document are reflected as styleSheet objects, but inline style defined with the (X)HTML style attribute is not. If you want to modify the style of a particular object, you should use the object s style or runtimeStyle property to access its Style or runtimeStyle object, which can then be directly manipulated.

It is important to notice that access to the individual rule s of a style sheet is achieved in different ways in Mozilla/Netscape/DOM2 and in Internet Explorer. In DOM2 you use the standard DOM2 collection cssRules[] , whereas in Internet Explorer you use the non-standard rules[] collection. In addition, different methods are used to add and delete rules.

Properties

Methods

Support

Internet Explorer 4+, Mozilla/Netscape 6+, DOM2.

sub, HTMLElement (Document Object)

This object corresponds to a < sub > (subscript) element in the document. It is accessed using standard DOM methods like document.getElementById() .

Properties

This object only supports the properties listed in the Generic HTML Element object found at the beginning of this section.

Methods

This object only supports the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

Notes

You may see browsers like Mozilla identify this object as an HTMLSpanElement , though no such object exists in the DOM. The correct indication is HTMLElement , though Internet Explorer just indicates it as a generic object.

Submit, HTMLInputElement (Document Object)

This object corresponds to an < input type="submit" > form button. Access to this object is achieved through standard DOM methods or through the enclosing Form (via its elements[] array or by name ). Note that all Form s have a submit() method that can be directly invoked.

Properties

This object has the following properties, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This object has the following methods, in addition to those in the Generic HTML Element object found at the beginning of this section:

Support

Internet Explorer 3+, Mozilla, Netscape 2+, DOM1.

sup, HTMLElement (Document Object)

This object corresponds to a < sup > (superscript) element in the document. It is accessed using standard DOM methods like document.getElementById() .

Properties

This object only supports the properties listed in the Generic HTML Element object found at the beginning of this section.

Methods

This object only supports the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

Notes

You may see browsers like Mozilla identify this object as an HTMLSpanElement , though no such object exists in the DOM. The correct indication is HTMLElement , though Internet Explorer just indicates it as a generic object.

table, HTMLTableElement (Document Object)

This object corresponds to a < table > element in the document. Access to this object is achieved through standard DOM methods.

Properties

This object has the following properties, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This object has the methods listed here, in addition to those in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

Notes

This object also provides methods for moving forward and backward through pages of data when Explorer s proprietary data binding technology is in use. See MSDN for more information on data binding with tables.

tBody, tHead, tFoot, HTMLTableSection (Document Object)

This object corresponds to a < thead >, < tfoot >, or < tbody > tag in the document. Access to these objects is achieved through standard DOM methods. The tbodies[] collection of table objects provides access to tbody objects and the tHead and tFoot properties of a HTMLTableElement can be used to access thead and tfoot objects if they exist.

Properties

This object has the following properties, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This object has the following methods, in addition to those in the Generic HTML Element object found at the beginning of this section:

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

td, th, HTMLTableCellElement (Document Object)

This object corresponds to a < th > or < td > element in the document. Access to this object is achieved through standard DOM methods or through the cells[] collection of a tr / HTMLTableRowElement object.

Properties

This object has the following properties, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This element has the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

Text, HTMLInputElement (Document Object)

This object corresponds to a text input field (< input type="text" >) element in the document. This object can be accessed using standard DOM techniques or through its enclosing Form (via the elements[] collection or by name ). The most important aspect of this object to recall is that the string entered into the input box is accessed through the value property.

Properties

This object has the following properties, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This object has the following methods, in addition to those in the Generic HTML Element object found at the beginning of this section:

Support

Internet Explorer 3+, Mozilla, Netscape 2+, DOM1.

textarea, HTMLTextAreaElement (Document Object)

This object corresponds to a text area input field (< textarea >) element in the document. This object can be accessed using standard DOM techniques or through its enclosing Form (via the elements[] collection or by name ).

Properties

Methods

Support

Supported in Internet Explorer 3+, Mozilla, Netscape 2+, DOM1.

TextNode (Document Object)

Represents a string of text in the document parse tree as a DOM node for manipulation.

Properties

Methods

Notes

TextRange (Proprietary Browser Object)

An instance of this object is created by invoking createTextRange() as a method of the body, a button, or a form field. TextRange objects permit the programmer to examine and manipulate the text found in these elements as well as any HTML they contain. A brief summary is presented here, but as always see MSDN for complete information.

Properties

Methods

Support

Internet Explorer 4+.

TextRectangle (Proprietary Browser Object)

This Internet Explorer “specific object specifies a rectangle that contains a line of text in either an element or a TextRange object.

Properties

Methods

None.

Support

IE5+.

Notes

Object generally created from getBoundingClientRect() method of a TextRange object.

title, HTMLTitleElement (Document Object)

This object corresponds to the < title > element in the document head. You can access this property in most versions of IE through document.all[] or through document.getElementById() . More commonly, it is accessed via document.title or is traversed to via the head element.

Properties

This object has the following property, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This element has the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

Notes

Most implementations provide access to the title string through document.title and it is commonly used by developers in place of DOM facilities.

tr, HTMLTableRowElement (Document Object)

This object corresponds to a < tr > tag in the document. Access to this object is achieved through standard DOM methods or through the rows[] collection of a HTMLTableElement object.

Properties

This object has the following properties, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This object has the following methods, in addition to those in the Generic HTML Element object found at the beginning of this section:

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

tt, HTMLElement (Document Object)

This object corresponds to a < tt > (teletype font) element in the document. It is accessed using standard DOM methods like document.getElementById() .

Properties

This object only supports the properties listed in the Generic HTML Element object found at the beginning of this section.

Methods

This object only supports the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

Notes

You may see browsers like Mozilla identify this object as an HTMLSpanElement , though no such object exists in the DOM. The correct indication is HTMLElement , though Internet Explorer just indicates it as a generic object.

u, HTMLElement (Document Object)

This object corresponds to a < u > (underlined) element in the document. It is accessed using standard DOM methods like document.getElementById() .

Properties

This object only supports the properties listed in the Generic HTML Element object found at the beginning of this section.

Methods

This object only supports the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

Notes

You may see browsers like Mozilla identify this object as an HTMLSpanElement , though no such object exists in the DOM. The correct indication is HTMLElement , though Internet Explorer just indicates it as a generic object.

ul, UListElement (Document Object)

This object corresponds to a < ul > (unordered list) element in the document. Access to these objects is achieved through standard DOM methods such as document.getElementById() .

Properties

This object has the following properties, in addition to those in the Generic HTML Element object found at the beginning of this section:

Methods

This element only has the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

userProfile (Proprietary Browser Object)

This Internet Explorer “specific object allows scripts to read and set user profile information. The steps are Select Tools | Internet Options, select the Content tab, and enter the information in the My Profile section. The vCard user profile attributes that you can read and set with this object can be found at MSDN, and include information about the user s physical address, gender, contact information, and so on.

The reality of these attributes is that their use is extremely uncommon. The only attribute that might occasionally be used is vCard.Homepage, but even this is very rare.

Because the user is prompted whether to permit each action, requests for reading and setting profile data are queued and then processed in batch fashion. This improves the user experience by requiring only one prompt for a group of related requests .

Although the userProfile object might seem like a great way to get data from the user, the number of users who have taken the time to fill out their profile information is minimal, so for this reason, this object is of limited value.

Properties

None.

Methods

Support

Internet Explorer 4+.

Notes

Using this object successfully requires users to have filled out their profile information in their browser.

var, HTMLElement (Document Object)

This object corresponds to an occurrence of a < var > tag (variable declaration) in the document.

It is accessed using standard DOM methods like document.getElementById() .

Properties

This object only supports the properties listed in the Generic HTML Element object found at the beginning of this section.

Methods

This object only supports the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

Notes

You may see browsers like Mozilla identify this object as an HTMLSpanElement , though no such object exists in the DOM. The correct indication is HTMLElement , though Internet Explorer just indicates it as a generic object.

wbr (Proprietary Document Object)

This object corresponds to a (nonstandard) < wbr > tag, which is used to indicate a soft return within a < nobr > tag found in the document. Access to this object is often performed via document.all[] , though it should be accessible in most browsers through standard DOM methods as well.

Properties

This object only supports the properties listed in the Generic HTML Element object found at the beginning of this section.

Methods

This object only supports the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in IE4+, MOZ.

Notes

You may see browsers like Mozilla identify this object as an HTMLWBRElement , though no such object exists in the DOM. Opera identifies it as HTMLWbrElemen t and Internet Explorer just indicates it as a generic object.

Window (Browser Object)

This top-level object contains properties and methods that permit the examination and manipulation of a browser window. Access to a window s frames, document, events, and other features are all achieved through this object. If a window has frames, each frame is itself a Window object accessed via the window.frames[] array. This simplifies the organization of nested frames.

The Window is always in the context of client-side JavaScript, so its properties and methods could be accessed without the window. prefix. One place you'll need to be careful, though, is in event handlers. Because event handlers are bound to the Document , a Document property with the same name as a Window property (for example, open ) will mask out the Window property.

For this reason, you should always use the full window. syntax when addressing Window properties in event handlers.

Properties

Methods

Notes

Because each browser window (and frame) has its own Window object, you can access a function or variable in another window by accessing it as a Window property. For example, if a variable named page is defined in a window you have a reference to, you would access it as windowHandle.page . It is always a good idea to verify that the window reference you have and the data you are accessing are valid before using this technique.

xml (Proprietary Document Object)

This Internet Explorer object corresponds to an < xml > (XML data island) element in the document. Access to these objects is achieved through standard DOM methods such as document.getElementById() .

Properties

Methods

This method is often used with events to determine where user activity is taking place with respect to a particular element and to take special actions based on scroll bar manipulation. (IE5+)

Support

Internet Explorer 5+

Notes

Chapter 20 contains examples that use the < xml > tag and its related JavaScript object. Microsoft s documentation at MSDN contains further details.

xmp (Proprietary Document Object)

This object corresponds to the depreciated < xmp > tag, which renders text in a fixed-width font indicating an example. The < samp > tag and associated object should be used instead. However, interestingly the tag is supported in modern browsers and DOM properties are associated with them in supporting browsers.

Properties

This object only supports the properties listed in the Generic HTML Element object found at the beginning of this section.

Methods

This object only supports the methods listed in the Generic HTML Element object found at the beginning of this section.

Support

Supported in Internet Explorer 4+, Mozilla/Netscape 6+, DOM1.

Notes

This tag is deprecated and the associated object non-standard ”do not use.

You may see browsers like Mozilla identify this object as an HTMLSpanElement , though no such object exists in the DOM. The correct indication is HTMLElement , though Internet Explorer just indicates it as a generic object. Interestingly Opera identifies this object as the non-existent HTMLXMPElement.

Active Server Pages

error 'ASP 0113'

Script timed out

/viewer_r.asp

The ma

Категории