JavaScript Editor JavaScript Debugger     JavaScript Editor 



Team LiB
Previous Section Next Section

JavaScript Object Reference

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

  • accessKey Single character string indicating the hotkey that gives the element focus. (IE4+)

  • all[] Collection of elements enclosed by the object. (IE4+)

  • align String specifying the alignment of the element, for example, "left". This property is defined only for display elements such as b, big, cite, and so on. (IE4+)

  • attributes[] Collection of read-only attributes for the element. (IE5+, MOZ/N6+, DOM1)

  • begin Sets or retrieves delay before timeline begins playing the element. See MSDN. (IE5.5+, SMIL)

  • behaviorUrns[] Collection of DHTML Behaviors attached to the node. (IE5+)

  • canHaveChildren Read-only Boolean value indicating whether the element can have child nodes. (IE5+)

  • canHaveHTML Read-only Boolean indicating whether the element can enclose HTML markup. (IE5.5+)

  • childNodes[] Read-only collection of child nodes of the object. (IE5+, MOZ/N6+, DOM1)

  • children[] Read-only collection of child nodes. This is IE’s pre-DOM equivalent of childNodes[]. (IE4+)

  • className String holding value of the CSS class(es) the element belongs to. (IE4+, MOZ/N6+, DOM1)

  • clientHeight Read-only numeric value indicating the height of the element’s content area in pixels. (IE4+)

  • clientLeft Read-only numeric value indicating the difference between the offsetLeft property and the beginning of the element’s content area, in pixels. (IE4+)

  • clientTop Read-only numeric value indicating the difference between the offsetTop property and the beginning of the element’s content area, in pixels. (IE4+)

  • clientWidth Read-only numeric value indicating the width of the element’s content area in pixels. (IE4+)

  • contentEditable String determining whether the element’s content is editable. Values are "inherit", "true", or "false". A value of "inherit" means that it will inherit the contentEditable property of its parent (this value is the default). This property is useful for making table data cells editable. Elements with disabled set to true are not editable, no matter what value this property has. Corresponds to the contenteditable attribute. (IE5.5+)

  • currentStyle Read-only reference to the Style object reflecting all styles applied to the element, including global (default) style. (IE5+)

  • dir String holding the text direction of text enclosed by the element. If set, its value is either "ltr" (left to right) or "rtl" (right to left). (IE5+, MOZ/N6+, DOM1)

  • disabled Boolean indicating whether the element is disabled (grayed out). (IE4+)

  • document An undocumented reference to the Document in which the element is contained. (IE4+)

  • filters[] Collection of Microsoft CSS Filters applied to the element. (IE4+)

  • firstChild Read-only reference to the first child node of the element, if one exists (null otherwise). (IE5+, MOZ/N6+, DOM1)

  • hasMedia Read-only Boolean indicating whether the element is an HTML+TIME media element. (IE5.5+)

  • hideFocus Boolean indicating whether the object gives a visible cue when it receives focus. (IE5.5+)

  • id String holding the unique alphanumeric identifier for the element. Commonly assigned using the id HTML attribute and used as the target for getElementById(). This unique identifier is not only important for scripting, but also for binding of CSS. (IE4+, MOZ/N6+, DOM1)

  • innerHTML String holding the HTML content enclosed within the element’s tags. (IE4+, MOZ/N6+)

  • innerText String holding the text enclosed by the element’s tags. This text is not interpreted as HTML, so setting it to a value like “<b>Important</b>” will result in “<b>Important</b>” being displayed, rather than “Important” with boldfaced font. (IE4+)

  • isContentEditable Read-only Boolean indicating if the user can edit the element’s contents. (IE5.5+)

  • isDisabled Read-only Boolean indicating if the user can interact with the object. (IE5.5+)

  • isTextEdit Read-only Boolean indicating if a TextRange object can be created using the object. (IE4+)

  • lang String holding language code for the content the element encloses. Corresponds to the lang HTML attribute. For a full list of valid values, see RFC 1766 (http://www.ietf.org/rfc/rfc1766.txt?number=1766), which describes language codes and their formats. (IE4+, MOZ/N6+, DOM1)

  • language String indicating the scripting language in use. (IE4+)

  • lastChild Read-only reference to the last child node of the element, if one exists (null otherwise). (IE5+, MOZ/N6+, DOM1)

  • localName Read-only string indicating the "local" XML name for the object. (MOZ/N6+)

  • namespaceURI Read-only string indicating the XML Namespace URI for the object. (MOZ/N6+)

  • nextSibling Read-only reference to next sibling of the node, for example, if its parent has multiple children. (IE5+, MOZ/N6+, DOM1)

  • nodeName Read-only string containing name of the node, the name of the tag to which the object corresponds, for example, "H1". (IE5+, MOZ/N6+, DOM1)

  • nodeType Read-only number holding the DOM defined node type. For example, element nodes have node type 1. A list of the common node types can be found in the following table. (IE5+, MOZ/N6+, DOM1)

    Node Type Number

    Type

    Description

    Example

    1

    Element

    An HTML or XML element

    <p>…</p>

    2

    Attribute

    An attribute for an HTML or XML element

    align="center"

    3

    Text

    A fragment of text that would be enclosed by an HTML or XML element

    This is a text fragment!

    8

    Comment

    An HTML comment

    <!-- This is a comment -->

    9

    Document

    The root document object, namely the top element in the parse tree

    <html>

    10

    DocumentType

    A document type definition

    <!DOCTYPE HTML PUBLIC "-//W3C

    //DTD HTML 4.01 Transitional//EN"

    "http://www.w3.org/TR/html4/loose.dtd">

  • nodeValue String containing value within the node (or null if no value). (IE5+, MOZ/N6+, DOM1)

  • offsetHeight Read-only numeric value indicating the height of the element in pixels. (IE4+, MOZ/N6+)

  • offsetLeft Read-only numeric value indicating the pixel offset of the left edge of the element, relative to its offsetParent. (IE4+, MOZ/N6+)

  • offsetParent Read-only reference to the object relative to which the offsetHeight/Width/Left/Top is calculated. (IE4+, MOZ/N6+)

  • offsetTop Read-only numeric value indicating the pixel offset of the top edge of the element, relative to its offsetParent. (IE4+, MOZ/N6+)

  • offsetWidth Read-only numeric value indicating the width of the element in pixels. (IE4+, MOZ/N6+)

  • outerHTML String holding the HTML content enclosed within (and including) the element’s tags. (IE4+)

  • outerText String holding the text enclosed by (and including) the element’s tags. (IE4+)

  • ownerDocument Read-only reference to the Document in which the element is contained. (IE5+, MOZ/N6+, DOM1)

  • parentElement Reference to the node’s parent. This is IE’s pre-DOM equivalent of parentNode. (IE4+)

  • parentNode Read-only reference to the parent of the object (or null if none exists). (IE4+, MOZ/N6+, DOM1)

  • parentTextEditvRead-only reference to the innermost container element outside of the current object that is capable of creating a TextRange containing the current element. (IE4+)

  • prefixvRead-only string containing the "prefix" XML name for the object. (MOZ/N6+)

  • previousSibling Read-only reference to previous sibling of the node, for example, if its parent node has multiple children. (IE5+, MOZ/N6+, DOM1)

  • readyState Read-only string containing the current state of the object. Values include "uninitialized", "loading", "loaded", "interactive" (not finished loading but able to respond to user actions), and "complete". Objects progress through each of these states until they have completed loading, though some objects may skip some intermediate steps (for example, pass from "uninitialized" directly to "complete"). This property is very useful in determining whether an element has completed loading. However, you should always make sure the object exists in the Document before attempting to read this property (otherwise, a runtime error will be thrown because you would be attempting to read a property of an object not yet defined). Note that an <object>s readyState is given by the integers 0 through 4 (with the same meaning). (IE4+)

  • recordNumber Read-only numeric value indicating the record number of the data set from which the element was generated. (IE4+)

  • runtimeStyle Reference to the Style object that reflects the current (runtime) style characteristics of the element. (IE5+)

  • scopeName Read-only string containing the XML scope for the object. (IE5+)

  • scrollHeight Numeric read-only value indicating the total height in pixels of the element’s content area, no matter how much is displayed on screen. (IE4+)

  • scrollLeft Numeric value indicating the distance in pixels from the left edge of the object to the leftmost edge of the object that is currently displayed. (IE4+)

  • scrollTop Numeric value indicating the distance in pixels from the top edge of the object to the topmost edge that is currently displayed. (IE4+)

  • scrollWidth Numeric read-only value indicating the total width in pixels of the object’s content area, no matter how much is displayed on screen. (IE4+)

  • sourceIndex Read-only number indicating the index of the element in the document.all[] collection. (IE4+)

  • style Reference to the inline Style object for the element. (IE4+, N4+, DOM2)

  • syncMaster Specifies whether time container must synchronize with the element. See MSDN. (IE5.5+, SMIL)

  • tabIndex Numeric value indicating the tab order for the object. Elements with positive values for this property are tabbed to in order of increasing tabIndex (before any others). Elements with zero for this property (the default) are tabbed to in the order they occur in the document source. Elements with negative values are not tabbed to at all. (IE4+)

  • tagName String containing the name of the tag to which the object corresponds, for example, "H1." (IE5.5+, MOZ/N6+, DOM1)

  • tagUrn String containing the URN of the XML Namespace for the object. (IE5+)

  • timeContainer Sets or retrieves the type of timeline associated with the element. (IE5.5+, SMIL)

  • title String containing advisory text for the element. (IE4+, MOZ/N6+, DOM1)

  • uniqueID An auto-generated read-only unique id for this element. (IE5+)

Methods

  • addBehavior(url) Attaches the DHTML Behavior referenced by string url to the element. (IE5+)

  • addEventListener(whichEvent, handler, direction) Instructs the object to execute the function handler whenever an event of type given in the string whichEvent (for example, "click") occurs. The direction is a Boolean specifying the phase in which to fire, true for capture or false for bubbling. (MOZ/N6+, DOM2)

  • appendChild(newChild) Appends newChild to end of the node’s childNodes[] list. (IE5+, MOZ/N6+, DOM1 Core)

  • applyElement(newElement [, where]) “Applies” one element to another by enclosing one within the other. If where is omitted or has value "outside", the object referenced by newElement becomes the parent of the current element. Otherwise, newElement becomes the only child of the current element, enclosing all of the current element’s children. (IE5+)

  • attachEvent(whichHandler, theFunction) Attaches the function theFunction as a handler specified by the string whichHandler, for example, "onclick". (IE5+)

  • blur() Removes focus from the element. (IE5+ for most elements. For form fields N2+ or N3+ and IE3+ or IE4+ and DOM1, listed specifically for each object)

  • clearAttributes() Clears all nonessential HTML attributes from the element (leaves id, dir, etc.). (IE5+)

  • click() Simulates a mouse click at the object. (IE4+)

  • cloneNode(cloneChildren) Clones the node and returns the new clone. If cloneChildren is true, the returned node includes the recursively constructed subtree of clones of the node’s children. (IE5+, MOZ/N6+, DOM1 Core)

  • componentFromPoint(x, y) Returns a string that gives information about the pixel coordinate (x,y) in the client window with respect to the current element. The string returned may have one of the values in the following table. The return value specifies whether the coordinate is inside of the element (""), outside of the element ("outside"), or a part of the various scrolling mechanisms that may be displayed for the element.

    Return Value

    Component at the Given Coordinate

    ""

    Component is inside the client area of the object.

    "outside"

    Component is outside the bounds of the object.

    "scrollbarDown"

    Down scroll arrow is at the specified location.

    "scrollbarHThumb"

    Horizontal scroll thumb or box is at the specified location.

    "scrollbarLeft"

    Left scroll arrow is at the specified location.

    "scrollbarPageDown"

    Page-down scroll bar shaft is at the specified location.

    "scrollbarPageLeft"

    Page-left scroll bar shaft is at the specified location.

    "scrollbarPageRight"

    Page-right scroll bar shaft is at the specified location.

    "scrollbarPageUp"

    Page-up scroll bar shaft is at the specified location.

    "scrollbarRight"

    Right scroll arrow is at the specified location.

    "scrollbarUp"

    Up scroll arrow is at the specified location.

    "scrollbarVThumb"

    Vertical scroll thumb or box is at the specified location.

    "handleBottom"

    Bottom sizing handle is at the specified location.

    "handleBottomLeft"

    Lower-left sizing handle is at the specified location.

    "handleBottomRight"

    Lower-right sizing handle is at the specified location.

    "handleLeft"

    Left sizing handle is at the specified location.

    "handleRight"

    Right sizing handle is at the specified location.

    "handleTop"

    Top sizing handle is at the specified location.

    "handleTopLeft"

    Upper-left sizing handle is at the specified location.

    "handleTopRight"

    Upper-right sizing handle is at the specified location.

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+)

  • contains(element) Returns a Boolean indicating if the object given in element is contained within the element. (IE4+)

  • detachEvent(whichHandler, theFunction) Instructs the object to cease executing the function theFunction as a handler given the string whichHandler, for example, "onclick". (IE5+)

  • dispatchEvent(event) Causes the Event instance event to be processed by the object’s appropriate handler. Used to redirect events. (MOZ/N6+, DOM2)

  • dragDrop() Initiates a drag event at the element. (IE5.5+)

  • fireEvent(handler [, event]) Causes the event handler given by the string handler to fire. If an Event instance was passed as event, the new event created reflects the properties of event. (IE5.5+)

  • focus() Gives focus to the element.

  • getAdjacentText(where) Returns the string of text corresponding to the text string at position where, with respect to the current node. The where parameter is a string with the following values:

    Value of where

    String Returned

    "beforeBegin"

    Text immediately preceding element’s opening tag (back to but not including first element encountered).

    "afterBegin"

    Text immediately following the element’s opening tag (up to but not including the first nested element).

    "beforeEnd"

    Text immediately preceding the element’s closing tag (back to but not including the closing tag of the last enclosed element).

    "afterEnd"

    Text immediately following element’s closing tag (up to but not including the first following tag).

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+)

  • getAttribute(name) Returns a string containing the value of the attribute specified in the string name or null if it does not exist. (IE4+, MOZ/N6+, DOM1 Core)

  • getAttributeNode(name) Returns the attribute node corresponding to the attribute in the string name. (IE6+, MOZ/N6+, DOM1 Core)

  • getBoundingClientRect() Retrieves a TextRectangle with properties top, bottom, left, right indicating the pixel values of the rectangle in which the element’s content is enclosed. (IE5+)

  • getClientRects() Retrieves a collection of TextRectangle objects, which give the pixel coordinates of all bounding rectangles contained in the element. (IE5+)

  • getElementsByTagName(tagname) Retrieves a collection of elements corresponding to the tag given in string tagname. A value of "*" retrieves all tags. (IE5+, MOZ/N6+, DOM1 Core)

  • getExpression(propertyName) Retrieves the string giving the dynamic property expression for the property/attribute named propertyName. (IE5+)

  • hasAttribute(name) Returns a Boolean indicating if the attribute given in string name is defined for the node (explicitly or by default). (MOZ/N6+, DOM2 Core)

  • hasAttributes() Returns a Boolean indicating if any attributes are defined for the node. (MOZ/N6+, DOM2 Core)

  • hasChildNodes() Returns a Boolean indicating if the node has children. (IE5+, MOZ/N6+, DOM1 Core)

  • insertAdjacentElement(where, element) Inserts the element object given in element adjacent to the current element in the position given by the string where (IE5+).The possible values for where include these:

    Value of where

    Effect

    "beforeBegin"

    Inserts immediately before the object.

    "afterBegin"

    Inserts after the start of the object but before all other content.

    "beforeEnd"

    Inserts immediately before the end of the object, after all other content.

    "afterEnd"

    Inserts immediately after the end of the object.

  • insertAdjacentHTML(where, text) Inserts the HTML given in string text adjacent to the current element according to the string where. See table under insertAdjacentElement() for the meaning of this parameter. The text is parsed and added to the document tree. (IE5+)

  • insertAdjacentText(where, text) Inserts the text given in string text adjacent to the current element according to the string where. See table under insertAdjacentElement() for the meaning of this parameter. The text is not parsed as HTML. (IE5+)

  • insertBefore(newChild, refChild) Inserts node newChild in front of refChild in the childNodes[] list of refChild's parent node. (IE5+, MOZ/N6+, DOM1 Core)

  • isSupported(feature [, version]) Returns a Boolean indicating whether feature and version given in the argument strings are supported. (MOZ/N6+, DOM2 Core)

  • mergeAttributes(source [, preserve]) Merges all attributes, styles, and event handlers from the element node source into the current element. (IE5+)

  • normalize() Recursively merges adjacent text nodes in the sub-tree rooted at this element. (IE6+, MOZ/N6+, DOM1 Core)

  • releaseCapture() Disables universal mouse event capturing at that object. (IE5+)

  • removeAttribute(name) Removes attribute corresponding to string name from the node. (IE4+, MOZ/N6+, DOM1 Core)

  • removeAttributeNode(attribute) Removes the attribute node given by node attribute and returns the removed node. (IE6+, MOZ/N6+, DOM1 Core)

  • removeBehavior(id) Removes the DHTML Behavior associated with id (previously returned by attachBehavior()) from the element. (IE4+)

  • removeChild(oldChild) Removes oldChild from the node’s children and returns a reference to the removed node. (IE5+, MOZ/N6+, DOM1 Core)

  • removeEventListener(whichEvent, handler, direction) Removes function handler as a handler for the event given in the string whichEvent (for example, "click") for the phase given by the Boolean direction. (MOZ/N6+, DOM2)

  • removeExpression(propertyName) Removes dynamic property expression for the property given in the string propertyName. (IE5+)

  • replaceAdjacentText(where, text) Replaces the text at position where relative to the current node with the text (non-HTML) string text (IE5+). Possible values for where include

    Value of where

    Effect

    "beforeBegin"

    Replaces text immediately before the object (back to but not including first tag or end tag encountered).

    "afterBegin"

    Replaces text at the start of the object but before all other enclosed content (up to but not including first opening tag).

    "beforeEnd"

    Replaces text immediately before the end of the object, after all other content (back to but not including last tag or closing tag).

    "afterEnd"

    Replaces text immediately after the element’s closing tag (up to but not including the next tag).

  • replaceChild(newChild, oldChild) Replaces the node’s child node oldChild with node newChild. (IE5+, MOZ/N6+, DOM1 Core)

  • replaceNode(newNode) Replaces the current node with newNode. (IE5+)

  • scrollIntoView([alignToTop]) Causes the object to be immediately scrolled into the viewable area of the window. If alignToTop is true or omitted, the top of the object is aligned with the top of the window (if possible). Otherwise, if alignToTop is false, the object is scrolled so that the bottom of the object is aligned with the bottom of the viewable window. (IE4+)

  • setActive() Sets the object as the active object without giving it focus. (IE5.5+)

  • setAttribute(name, value) Sets a new attribute for the node with name and value given by the string arguments. (IE4+, MOZ/N6+, DOM1 Core)

  • setAttributeNode(newAttr) Adds the attribute node newAttr (replacing and returning any attribute node with the same name). (IE6+, MOZ/N6+, DOM1 Core)

  • setCapture([containerCapture]) Causes all mouse events occurring in the document to be sent to this object. (IE5+)

  • setExpression(property, expression [, language]) Sets the expression given in string expression as the dynamic expression for the property given in string property. The optional language parameter specifies which scripting language the expression is written in, for example, "VBscript" (JScript is the default). Commonly used as a method of element nodes and Style objects. Used for setting dynamic expressions. (IE5+)

  • swapNode(node) Exchanges the location of the object with node in the object hierarchy. (IE5+)

  • unwatch(property) Removes the watchpoint on the property given in the string property. (N4+)

  • watch(property, handler) “Watches” the property given in string property and invokes the function handler whenever its value changes. The handler is passed the name of the property, the old value, and the value to which it is being set. Any value the function returns is interpreted as the new value for the property. (N4+)

Notes

  • With the exception of the object scriptable under traditional models (Form, Image, and so on), most elements become scriptable in Internet Explorer 4+, Mozilla/Netscape 6+, and DOM1.

  • HTML elements are referred to both in uppercase and lowercase under the DOM, so <p> and <P> are both equivalent to an HTMLParagraph object.

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:

  • accessKey Single character string indicating the hotkey that gives the element focus. (IE4+, MOZ/N6+, DOM1)

  • charset String indicating the character set of the linked document. (IE6+, MOZ/N6+, DOM1)

  • coords String (comma-separated list) defining the coordinates of the object, used with the shape attribute. However, there is no default functionality. (IE6+, MOZ/N6+, DOM1)

  • dataFld String specifying which field of a data source is bound to the element. (IE4+)

  • dataFormatAsv String indicating how the element treats data supplied to it. (IE4+)

  • dataSrc String containing the source of data for data binding. (IE4+)

  • disabled Boolean indicating whether the element is disabled (grayed out). (IE4+)

  • hash String holding the portion of the URL in the href following the hash mark (#). Defined for Link in traditional models. (IE3+, N2+, MOZ)

  • host String holding the domain name and port portion of the URL in the href. Defined for Link in traditional models. (IE3+, N2+, MOZ)

  • hostname String holding the domain name portion of the URL in the href. Defined for Link in traditional models. (IE3+, N2+, MOZ)

  • href String holding the value of the href attribute, the document to load when the link is activated. Defined for Link in traditional models. (IE3+, N2+, MOZ, DOM1)

  • hreflang String indicating the language code of the linked resource. (MOZ/N6+, IE6+, DOM1)

  • media String indicating the media of the link. Currently unsupported. (DOM1)

  • name String containing the value of the name attribute. Defined for Anchor in traditional models. In some browsers this is a read-only value. (IE3+, N4+, MOZ, DOM1)

  • nameProp String holding the filename portion of the URL in the href. (IE5+)

  • pathname String holding the path and filename portion of the URL in the href (including the leading slash). Defined for Link in traditional models. (IE3+, N2+, MOZ)

  • port String holding the port number portion of the URL in the href. Defined for Link in traditional models. (IE3+, N2+, MOZ)

  • protocol String holding the protocol portion of the URL in the href. Defined for Link in traditional models. (IE3+, N2+, MOZ)

  • protocolLong A read-only string holding the full name of the protocol used in the URL in the href. Defined for Link in traditional models. (IE4+)

  • rel String holding the value of the rel property of the element. Used to specify the relationship between documents, but currently ignored by most browsers. (IE4+, MOZ/N6+, DOM1)

  • rev String holding the value of the rel property of the element. Used to specify the relationship between documents. The use of this attribute is currently ignored by most browsers. (IE4+, MOZ/N6+, DOM1)

  • search String holding the portion of the URL in the href following the question mark (a.k.a. the search string). Defined for Link in traditional models. (IE3+, N2+, MOZ/N6+)

  • shape String defining the shape of the object. (IE6+, MOZ/N6+, DOM1)

  • tabIndex Numeric value indicating the tab order for the object. (IE4+, MOZ/N6+, DOM1)

  • target Specifies the target window for a hypertext source link referencing frames. (IE3+, N2+, MOZ, DOM1)

  • text A read-only string specifying the text enclosed by the <a></a> tags. Defined for Anchor in traditional models. More appropriately accessed via DOM methods. (N4+)

  • type Specifies the media type in the form of a MIME type for the link target. (IE6+, MOZ/N6+, DOM1)

  • urn Defines a URN for a target document. (IE4+)

  • x The read-only x coordinate of an Anchor, in pixels, relative to the left edge of the document. (N4)

  • y The read-only y coordinate of an Anchor, in pixels, relative to the top edge of the document. (N4)

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:

  • blur() Removes focus from the element. (IE4+, MOZ/N6+, DOM1)

  • handleEvent(event) Causes the Event instance event to be processed by the appropriate handler of the object. (N4)

  • focus() Gives the element focus. (IE4+, MOZ/N6+, DOM1)

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.

  • align String specifying the alignment of the element, for example, "left". (IE4+, MOZ/N6+, DOM1)

  • alt String specifying alternative text for the applet. (IE6, MOZ/N6+, DOM1)

  • altHtml String specifying alternative markup for the applet if the applet doesn’t load. (IE4+)

  • archive String containing a comma-separated list of URLs giving classes required by the applet that should be preloaded. (IE6, MOZ/N6+, DOM1)

  • code String containing the URL of the Java applet’s class file. (IE4+, MOZ/N6+, DOM1)

  • codeBase String containing the base URL for the applet (for relative links). (IE4+, MOZ/N6+, DOM1)

  • dataFld String specifying which field of a data source is bound to the element. (IE4+)

  • dataFormatAs String indicating how the element treats data supplied to it. (IE4+)

  • dataSrc String containing the source of data for data binding. (IE4+)

  • height String specifying the height in pixels of the object. (IE4+, MOZ/N6+, DOM1)

  • hspace String specifying the horizontal margin to the left and right of the applet. (IE4+, MOZ/N6+, DOM1)

  • name String holding the name attribute of the applet. (IE4+, MOZ/N6+, DOM1)

  • src String specifying the URL of the applet. Non-standard and should be avoided. (IE4+)

  • object String containing the name of the resource that contains a serialized representation of the applet. Either code or object is used, but not both. (IE4+, MOZ/N6+, DOM1)

  • vspace String specifying the vertical margin above and below the applet. (IE4+, MOZ/N6+, DOM1)

  • width Specifies the width of the object in pixels. (IE4+, MOZ/N6+, DOM1)

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:

  • accessKey Single character string indicating the hotkey that gives the element focus. (IE4+, MOZ/N6+, DOM1)

  • alt String defining text alternative to the graphic. (IE4+, MOZ/N6+, DOM1)

  • coords String defining the (comma-separated) coordinates of the object, used with the shape attribute. (IE6+, MOZ/N6+, DOM1)

  • hash String holding the portion of the URL in the href following the hash mark (#). (IE3+, N3+, MOZ)

  • host String holding the domain name and port portion of the URL in the href. (IE3+, N3+, MOZ)

  • hostname String holding the domain name portion of the URL in the href. (IE3+, N3+, MOZ)

  • href String holding the value of the href attribute, the document to load when the link is activated. (IE3+, N3+, MOZ, DOM1)

  • noHref Boolean indicating that the links for this area are disabled. (IE3+, MOZ/N6+, DOM1)

  • pathname String holding the path and file name portion of the URL in the href (including the leading slash). Defined for Link in traditional models. (IE3+, N2+, MOZ)

  • port String holding the port number portion of the URL in the href. (IE3+, N3+, MOZ)

  • protocol String holding the protocol portion of the URL in the href. (IE3+, N3+, MOZ)

  • search String holding the portion of the URL in the href following the question mark (also called the search string). (IE3+, N3+, MOZ)

  • shape String defining the shape of the object, usually "default" (entire region), "rect" (rectangular), "circle" (circular), or "poly" (polygon). (IE4+, MOZ/N6+, DOM1)

  • tabIndex Numeric value indicating the tab order for the object. (IE4+, MOZ/N6+, DOM1)

  • target Specifies the target window for a hypertext source link referencing frames. (IE3+, N3+, MOZ, DOM1)

  • x This Netscape 4–specific property, which is read-only, contains the x coordinate of the link in pixels, relative to the left edge of the document. (N4)

  • y This Netscape 4–specific property, which is read-only, contains the y coordinate of the link in pixels, relative to the top edge of the document. (N4)

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:

  • handleEvent(event) Causes the Event instance event to be processed by the appropriate handler of the object. (N4 only)

Support

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

Array (Built-in Object)

Arrays 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

  • constructor Reference to the constructor object, which created the object. (IE4+ (JScript 2.0+), MOZ, N3+ (JavaScript 1.1+), ECMA Edition 1)

  • length Numeric value indicating the next empty index at the end of the array (not the number of elements in the array). Setting this property to a value less than its current value will undefine any elements with index >= length. (IE4+ (JScript 2.0+), MOZ, N3+ (JavaScript 1.1+), ECMA Edition 1)

  • prototype Reference to the object’s prototype. (IE4+ (JScript 2.0+), MOZ, N3+ (JavaScript 1.1+), ECMA Edition 1)

Methods

  • concat([item1 [, item2 [, ...]]]) Appends the comma-separated list of items to the end of the array and returns the new array (it does not operate on the array in place). If any item is an array, its first level is flattened (that is, the item’s elements are appended each as a separate element). (IE4+ (JScript 3.0+), MOZ, N4+ (JavaScript 1.2+), ECMA Edition 1)

  • join([separator]) Returns the string obtained by concatenating all the array’s elements. If the string separator is supplied, separator will be placed between adjacent elements. The separator defaults to a comma. (IE4+ (JScript 2.0+), MOZ, N3+ (JavaScript 1.1+), ECMA Edition 1)

  • pop() Removes the last element of the array and returns it. (IE5.5+ (JScript 5.5+), MOZ, N4+ (JavaScript 1.2+), ECMA Edition 3)

  • push([item1 [, item2 [, ...]]]) Appends the parameters (in order) to the end of the array and returns the new length. (IE5.5+ (JScript 5.5+), MOZ, N4+ (JavaScript 1.2+), ECMA Edition 3)

  • reverse() Reverses the order of the elements (in place). (IE4+ (JScript 2.0+), MOZ, N3+ (JavaScript 1.1+), ECMA Edition 1)

  • shift() Removes the first element from the array, returns it, and shifts all other elements down one index. (IE5.5+ (JScript 5.5+), MOZ, N4+ (JavaScript 1.2+), ECMA Edition 3)

  • slice(begin [, end]) Returns a new array containing the elements from index begin up to but not including index end. If end is omitted, all elements to the end of the array are extracted. If end is negative, it is treated as an offset from the end of the array. (IE4+ (JScript 3.0+), MOZ, N4+ (JavaScript 1.2), ECMA Edition 3)

  • sort([compareFunc]) Sorts the array in place in lexicographic order. The optional argument compareFunc is a function that can change the behavior of the sort. It will be passed two elements and should return a negative value if the first element is less than the second, a positive value if the second is less than the first, or zero if they are equal. (IE4+ (JScript 2.0+), MOZ, N3+ (JavaScript 1.1+), ECMA Edition 1)

  • splice(start, howMany [, item1 [, item2 [, ...]]]) Removes howMany elements from the array beginning at index start and replaces the removed elements with the itemN arguments (if passed). An array containing the deleted elements is returned. (IE5.5+ (JScript 5.5+), MOZ, N4+ (JavaScript 1.2+), ECMA Edition 3)

  • toString() Returns a string containing the comma-separated list of elements. (IE4+ (JScript 2.0+), MOZ, N3+ (JavaScript 1.1+), ECMA Edition 1)

  • unshift([item1 [, item2 [, ...]]]) Inserts the items (in order) at the front of the array, shifting existing values up to higher indices. (IE5.5+ (JScript 5.5+), MOZ, N4+ (JavaScript 1.2+), ECMA Edition 3)

  • valueOf() Same as toString(). (IE4+ (JScript 2.0+), MOZ, N3+ (JavaScript 1.1+), ECMA Edition 1)

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:

  • href String holding the URL relative to which all relative URLs on the page are fetched. (IE4+, MOZ/N6+, DOM1)

  • target String holding the name of the target window or frame for all links on the page. (IE4+, MOZ/N6+, DOM1)

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:

  • color String holding the default text color for the page. (IE4+, MOZ/N6+, DOM1)

  • face String holding a comma-separated list of one or more default font names. (IE4+, MOZ/N6+, DOM1)

  • size String holding the default font size (HTML 1–7 or relative +n/–n syntax). (IE3+, MOZ/N6+, DOM1)

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:

  • balance Numeric value from 10,000 to –10,000 indicating the proportion of sound that should come from the left speaker versus the right. (IE4+)

  • loop Numeric value with –1 indicating the sound should loop forever, 0 indicating it should play once, and positive values indicating the number of times the sound should play. (IE4+)

  • src String indicating the URL of the sound. (IE4+)

  • volume Numeric value from –10,000 (softest) to 0 (loudest). (IE4+)

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.

  • cite String containing the URL of a reference for the quote. (IE6+, MOZ/N6+, DOM1)

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:

  • aLink String specifying the color of active links. (IE4+, MOZ/N6+, DOM1)

  • background String specifying the URL of an image to use as a background for the document. (IE4+, MOZ/N6+, DOM1)

  • bgColor String specifying the background color of the document. The browser will generally turn set color values to #RRGGBB hex regardless of being entered that way or not. (IE4+, MOZ/N6+, DOM1)

  • bgProperties String specifying other background properties for the document. When it has the value "fixed", the background image is fixed and will not scroll. (IE4+)

  • bottomMargin, leftMargin, rightMargin, topMargin Sets the margins for the entire body of the page (in pixels) and overrides the default margins. (IE4+)

  • link String specifying the color of unvisited links. (IE4+, MOZ/N6+, DOM1)

  • noWrap Boolean indicating whether the browser automatically performs word wrapping. (IE4+)

  • scroll String specifying whether scrollbars are visible. Values are "yes", "no", and "auto". (IE4+)

  • text String specifying the text color for the document. (IE3+, MOZ/N6+, DOM1)

  • timeStartRule String specifying HTML+TIME timing functionality. (IE5+)

  • vLink String specifying the color of visited links. (IE4+, MOZ/N6+, DOM1)

Methods

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

  • createControlRange() Creates a controlRange object for the document and returns a reference to it. (IE5+)

  • createTextRange() Creates a TextRange object for the document and returns a reference to it. (IE5+)

  • doScroll([action]) Scrolls the top of the body of the document into view. If action is specified it must be one of several predetermined strings, such as "left" or "right", that give fine-grained control over scroll bar actions. See MSDN for complete details. (IE5+)

  • pause() Pauses the timeline on the document (related to HTML+TIME). See MSDN. (IE5+)

  • resume() Resumes the timeline on the document (related to HTML+TIME). See MSDN. (IE5+)

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

  • constructor Reference to the constructor object, which created the object. (IE4+ (JScript 2.0+), MOZ, N3+ (JavaScript 1.1+), ECMA Edition 1)

  • prototype Reference to the object’s prototype. (IE4+ (JScript 2.0+), MOZ, N3+ (JavaScript 1.1+), ECMA Edition 1)

Methods

  • toString() Returns the string version of the value, either "true" or "false". (IE4+ (JScript 2.0+), MOZ, N3+ (JavaScript 1.1+), ECMA Edition 1)

  • valueOf() Returns the primitive Boolean value of the object. (IE4+ (JScript 2.0+), MOZ, N3+ (JavaScript 1.1+), ECMA Edition 1)

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:

  • clear String specifying how the element flows with surrounding text. Typical values are "left", "right", or "all". (IE4+, MOZ/N6+)

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.

  • accessKey Single character string indicating the hotkey that gives the element focus. (IE4+, MOZ/N6+, DOM1)

  • dataFld String specifying which field of a data source is bound to the element. (IE4+)

  • dataFormatAs String indicating how the element treats data supplied to it. (IE4+)

  • dataSrc String containing the source of data for data binding. (IE4+)

  • disabled Boolean indicating whether the element is disabled (grayed out). (IE4+, MOZ/N6+, DOM1)

  • form A read-only reference to the Form in which the button is contained, if one exists. (IE4+, MOZ/N6+, DOM1)

  • name String holding the name attribute of the element. (IE4+, MOZ/N6+, DOM1)

  • tabIndex Numeric value indicating the tab order for the object. (IE4+, MOZ/N6+, DOM1)

  • type String indicating the type of the button, either "button", "reset", or "submit". (IE4+, MOZ/N6+, DOM1)

  • value String containing the text of the value attribute of the button. (IE4+, MOZ/N6+, DOM1)

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:

  • accessKey Single character string indicating the hotkey that gives the element focus. (IE4+, MOZ/N6+, DOM1)

  • align String specifying the alignment of the element, for example, "left". (IE4+, MOZ/N6+, DOM1)

  • dataFld String specifying which field of a data source is bound to the element. (IE4+)

  • dataFormatAs String indicating how the element treats data supplied to it. (IE4+)

  • dataSrc String containing the source of data for data binding. (IE4+)

  • defaultValue String holding the original value of the value attribute. (IE4+, MOZ/N6+, DOM1)

  • disabled Boolean indicating whether the element is disabled (grayed out). (IE4+, MOZ/N6+, DOM1)

  • form Read-only reference to the Form in which the button is contained. (IE3+, MOZ, N2+, DOM1)

  • name String holding the name attribute of the element. (IE3+, MOZ, N2+, DOM1)

  • size String indicating the width of the button in pixels. (IE4+, MOZ/N6+, DOM1)

  • tabIndex Numeric value indicating the tab order for the object. (IE4+, MOZ/N6+, DOM1)

  • type Read-only string indicating the type of the field which should be "button". (IE4+, MOZ, N3+, DOM1)

  • value String containing the text of the value attribute of the button. (IE3+, MOZ, N2+, DOM1)

Methods

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

  • blur() Causes the button to lose focus. (IE3+, MOZ, N2+, DOM1)

  • click() Simulates a click on the button. (IE3+, MOZ, N2+, DOM1)

  • focus() Gives the button focus. (IE3+, MOZ, N2+, DOM1)

  • handleEvent(event) Causes the Event instance event to be processed by the appropriate handler of the object. (N4 only)

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:

  • align String specifying the alignment of the element, for example "top" or "left". (IE4+, MOZ/N6+, DOM1)

  • vAlign String specifying the vertical alignment of the element ("bottom" or "top"). (IE4+)

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:

  • accessKey Single character string indicating the hotkey that gives the element focus. (IE4+, MOZ/N6+, DOM1)

  • align String specifying the alignment of the element, for example, "left". (MOZ/N6+, DOM1)

  • checked Boolean indicating whether the checkbox is checked. (IE3+, MOZ, N2+, DOM1)

  • dataFld String specifying which field of a data source is bound to the element. (IE4+)

  • dataSrc String containing the source of data for data binding. (IE4+)

  • defaultChecked Boolean indicating if the checkbox was checked by default. (IE3+, MOZ, N2+, DOM1)

  • defaultValue String containing the original value of the checkbox’s value attribute. (IE3+, MOZ, DOM1)

  • disabled Boolean indicating whether the element is disabled (grayed out). (IE4+, MOZ/N6+, DOM1)

  • form Read-only reference to the Form in which the button is contained, if one exists. (IE3+, MOZ, N2+, DOM1)

  • height The height in pixels of the checkbox. (IE5+)

  • name String holding the name attribute of the element. (IE3+, MOZ, N2+, DOM1)

  • size String indicating the width in pixels. (IE3+, MOZ/N6+, DOM1)

  • status Boolean indicating whether the checkbox is currently selected. (IE4+)

  • tabIndex Numeric value indicating the tab order for the object. (IE4+, MOZ/N6+, DOM1)

  • type A read-only string indicating the type of the field, which should be "checkbox". (IE3+, MOZ, N3+, DOM1)

  • value String containing the text of the value attribute. (IE3+, MOZ, N2+, DOM1)

  • width The width in pixels of the checkbox. (IE5+)

Methods

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

  • blur() Causes the checkbox to lose focus. (IE3+, MOZ, N2+, DOM1)

  • click() Simulates a click on the checkbox. (IE3+, MOZ, N2+, DOM1)

  • focus() Gives the checkbox focus. (IE3+, MOZ, N2+, DOM1)

  • handleEvent(event) Causes the Event instance event to be processed by the appropriate handler of the object. (N4 only)

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

  • clearData([dataFormat]) Removes all data from the clipboard unless the string dataFormat is specified as "Text", "URL", "File", "HTML", or "Image", in which case only data of that kind is cleared. (IE5+ Windows)

  • getData(dataFormat) Gets data of the specified format from the clipboard and returns it as a string (of text, HTML, or a URL). (IE5+ Windows)

  • setData(dataFormat, data) Attempts to place the data given in string data (either text, HTML, or a URL) into the clipboard according to the data type specified in the string dataType (either Text, URL, File, HTML, or Image). Returns a Boolean indicating whether it was successful. (IE5+ Windows)

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:

  • align String specifying the horizontal alignment of the element, for example, "left". (IE4+, MOZ/N6+, DOM1)

  • ch String specifying the alignment character for the column. This property/attribute is generally not supported by browsers, but is provided in case programmers wish to implement the functionality themselves. (IE6+, MOZ/N6+, DOM1)

  • chOff String specifying the offset of the first occurrence of the alignment character for the column. This property/attribute is generally not supported by browsers but is provided in case programmers wish to implement the functionality themselves. (IE6+, MOZ/N6+, DOM1)

  • span Integer indicating the number of columns in the group or spanned by the column. (IE4+, MOZ/N6+, DOM1)

  • vAlign String specifying the vertical alignment of the column data (for example, "top"). (IE4+, MOZ/N6+, DOM1)

  • width Specifies the width of the column in pixels. (IE4+, MOZ/N6+, DOM1)

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

  • dropEffect Holds the type of drag-and-drop operation and the type of cursor to display. Allowed values are "copy", "link", "move", and "none", with the default value being none. (IE5+)

  • effectAllowed Holds the definition of the data transfer operations, which are allowed for the source element in the drag-and-drop. Allowed values include "copy," "link," "move", "copyLink", "copyMove", "linkMove", "all", "none", and "unitialized". The default value is uninitialized, which allows the drag-and-drop effect to work though its type is not queriable via the property. (IE5+)

Methods

  • clearData([sDataFormat]) Clears the data in the dataTransfer object. The optional sDataFormat parameter can be set to "Text", "URL", "File", "HTML", or "Image" to indicate the type of data to remove. (IE 5+)

  • getData(sDataFormat) Returns the data in the defined sDataFormat (either "Text" or "URL") from the dataTransfer or clipboardData object. (IE 5+)

  • setData(sDataFormat,sData) Assigns string data defined by sData in the specified format defined by sDataFormat (either "Text" or "URL") to the dataTransfer or clipboardData object (IE5+)

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

  • constructor Reference to the constructor object, which created the object. (IE4+ (JScript 2.0+), MOZ, N3+ (JavaScript 1.1+), ECMA Edition 1)

  • prototype Reference to the object’s prototype. (IE4+ (JScript 2.0+), MOZ, N3+ (JavaScript 1.1+), ECMA Edition 1)

Methods

  • getDate() Returns a numeric value indicating the day of the month (1-based). (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1)

  • getDay() Returns a numeric value indicating the day of the week (0 for Sunday, 1 for Monday, and so on). (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1)

  • getFullYear() Returns a numeric value indicating the four-digit year. (IE4+ (JScript 3.0+), MOZ, N4.06+ (JavaScript 1.3+), ECMA Edition 1)

  • getHours() Returns a numeric value indicating the hours since midnight (0-based). (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1)

  • getMilliseconds() Returns a numeric value indicating the number of milliseconds (0-999). (IE4+ (JScript 3.0+), MOZ, N4.06+ (JavaScript 1.3+), ECMA Edition 1)

  • getMinutes() Returns a numeric value indicating the number of minutes (0–59). (IE4+ (JScript 3.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1)

  • getMonth() Returns a numeric value indicating the number of months since the beginning of the year (0–11; 0 is January). (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1)

  • getSeconds() Returns a numeric value indicating the number of seconds (0–59). (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1)

  • getTime() Returns a numeric value indicating the number of milliseconds since the epoch. Dates before the epoch return a negative value indicating the number of milliseconds before the epoch. (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1)

  • getTimezoneOffset() Returns a numeric value indicating the difference in minutes between the local time and the UTC. Positive values indicate the local time is behind UTC (for example, in the United States) and negative values indicate the local time is ahead of UTC (for example, in India). (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1)

  • getUTCDate() Returns a numeric value indicating the day of the month (1-based) using UTC. (IE4+ (JScript 3.0+), MOZ, N4.06+ (JavaScript 1.3+), ECMA Edition 1)

  • getUTCDay() Returns a numeric value indicating the day of the week (0 for Sunday, 1 for Monday, and so on) according to UTC. (IE4+ (JScript 3.0+), MOZ, N4.06+ (JavaScript 1.3+), ECMA Edition 1)

  • getUTCFullYear() Returns a numeric value indicating the four-digit year according to UTC. (IE4+ (JScript 3.0+), MOZ, N4.06+ (JavaScript 1.3+), ECMA Edition 1)

  • getUTCHours() Returns a numeric value indicating the hours since midnight (0-based) according to UTC. (IE4+ (JScript 3.0+), MOZ, N4.06+ (JavaScript 1.3+), ECMA Edition 1)

  • getUTCMilliseconds() Returns a numeric value indicating the number of milliseconds (0–999) according to UTC. (IE4+ (JScript 3.0+), MOZ, N4.06+ (JavaScript 1.3+), ECMA Edition 1)

  • getUTCMinutes() Returns a numeric value indicating the number of minutes (0–59) according to UTC. (IE4+ (JScript 3.0+), MOZ, N4.06+ (JavaScript 1.3+), ECMA Edition 1)

  • getUTCMonth() Returns a numeric value indicating the number of months since the beginning of the year (0–11; 0 is January) according to UTC. (IE4+ (JScript 3.0+), MOZ, N4.06+ (JavaScript 1.3+), ECMA Edition 1)

  • getUTCSeconds() Returns a numeric value indicating the number of seconds (0–59) according to UTC. (IE4+ (JScript 3.0+), MOZ, N4.06+ (JavaScript 1.3+), ECMA Edition 1)

  • getYear() Returns the current year minus 1900 or in some cases a four-digit year if the year is greater than 1999. This method is deprecated; use getFullYear() instead. (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1)

  • getVarYear() Returns the VT_DATE corresponding to the object. For use with interaction with COM or VBScript, but in general should be avoided. (IE4+ (JScript 3.0+))

  • parse(stringDate) Attempts to parse the date given in the string stringDate and if successful returns the number of milliseconds of the date relative to the epoch. Valid strings are given in Chapter 7 but in general can be any common representation of a date, for example "month/day/year", "month day, year", or "month day, year hh:mm:ss". Unambiguous shorthand (for example, "Dec" for December) is permitted. If the date cannot be parsed, NaN is returned. (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1, Static)

  • setDate(dayOfMonth) Sets the day of the month (1-based) in local time as given by the numeric parameter dayOfMonth. (IE4+ (JScript 3.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1)

  • setFullYear(year [, month [, day]]) Sets the date to the year given in the numeric argument year in local time. If the numeric parameters month and day are passed, the month (0-based) and day of the month (1-based) are set as well. If month is greater than 11, the year is incremented accordingly. If day is greater than the number of days in the month, the month is incremented accordingly. (IE4+ (JScript 3.0+), MOZ, N4.06+ (JavaScript 1.3+), ECMA Edition 1)

  • setHours(hours [, mins [, secs [, ms]]]) Sets the hours (0-based) to the numeric argument given in hours in local time. If the optional parameters are passed, the minutes, seconds, and milliseconds are set accordingly. If any of the parameters is greater than the normal range of values, the date is adjusted accordingly (for example, 60 seconds increments the minutes by one and sets the seconds to zero). (IE4+ (JScript 3.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1)

  • setMilliseconds(ms) Sets the milliseconds (0-based) to the numeric argument ms in local time. If ms is greater than 999, the seconds are adjusted accordingly. (IE4+ (JScript 3.0+), MOZ, N4.06+ (JavaScript 1.3+), ECMA Edition 1)

  • setMinutes(minutes [, secs [, ms]]) Sets the minutes (0-based) to the numeric argument minutes in local time. If numeric arguments secs and ms are supplied, the seconds and milliseconds are set to these values. If any argument is greater than the normal range, appropriate values are incremented accordingly (for example, if secs is 60, the minute is incremented by one and the seconds set to zero). (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1)

  • setMonth(month [, day]) Sets the month (0-based) to the numeric argument month in local time. If the numeric argument day is supplied, the day of the month (1-based) is set accordingly. If either value is outside of the expected range, the date is adjusted accordingly (for example, if month is 12 the year is incremented and the month is set to zero). (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1)

  • setSeconds(seconds [, ms]) Sets the seconds (0-based) to the numeric argument seconds in local time. If numeric argument ms is supplied, the milliseconds (0-based) are set accordingly. If either value is outside the expected range, the date is adjusted accordingly (for example, if ms is 1000, then the seconds are incremented and milliseconds set to 0). (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1)

  • setTime(ms) Sets the date to the date given by the number of milliseconds since the epoch given in ms. Negative values of ms specify dates before the epoch. (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1)

  • setUTCDate(dayOfMonth) Sets the day of the month (1-based) in UTC as given by the numeric parameter dayOfMonth. (IE4+ (JScript 3.0+), MOZ, N4.06+ (JavaScript 1.3+), ECMA Edition 1)

  • setUTCFullYear(year [, month [, day]]) Sets the date to the year given in the numeric argument year in UTC. If the numeric parameters month and day are passed, the month (0-based) and day of the month (1-based) are set as well. If month is greater than 11, the year is incremented accordingly. If day is greater than the number of days in the month, the month is incremented accordingly. (IE4+ (JScript 3.0+), MOZ, N4.06+ (JavaScript 1.3+), ECMA Edition 1)

  • setUTCHours(hours [, mins [, secs [, ms]]]) Sets the hours (0-based) to the numeric argument given in hours in UTC. If the optional parameters are passed, the minutes, seconds, and milliseconds are set accordingly. If any of the parameters is greater than the normal range of values, the date is adjusted accordingly (for example, a value of 60 seconds increments the minutes by one and sets the seconds to zero). (IE4+ (JScript 3.0+), MOZ, N4.06+ (JavaScript 1.3+), ECMA Edition 1)

  • setUTCMilliseconds(ms) Sets the milliseconds (0-based) to the numeric argument ms in UTC. If ms is greater than 999, the seconds are adjusted accordingly. (IE4+ (JScript 3.0+), MOZ, N4.06+ (JavaScript 1.3+), ECMA Edition 1)

  • setUTCMinutes(minutes [, secs [, ms]]) Sets the minutes (0-based) to the numeric argument minutes in UTC. If numeric arguments secs and ms are supplied, the seconds and milliseconds are set to these values. If any argument is greater than the normal range, appropriate values are incremented accordingly (for example, if secs is 60, the minute is incremented by one and the seconds set to zero). (IE4+ (JScript 3.0+), MOZ, N4.06+ (JavaScript 1.3+), ECMA Edition 1)

  • setUTCMonth(month [, day]) Sets the month (0 based) to the numeric argument month in UTC. If the numeric argument day is supplied, the day of the month (1-based) is set accordingly. If either value is outside of the expected range, the date is adjusted accordingly (for example, if month is 12, the year is incremented and the month is set to zero). (IE4+ (JScript 3.0+), MOZ, N4.06+ (JavaScript 1.3+), ECMA Edition 1)

  • setUTCSeconds(seconds [, ms]) Sets the seconds (0-based) to the numeric argument seconds in UTC. If numeric argument ms is supplied, the milliseconds (0-based) are set accordingly. If either value is outside the expected range, the date is adjusted accordingly (for example, if ms is 1000, then the seconds are incremented and milliseconds set to 0). (IE4+ (JScript 3.0+), MOZ, N4.06+ (JavaScript 1.3+), ECMA Edition 1)

  • setYear(year) This method is deprecated; use setFullYear() instead. Sets the year to the numeric value year in local time. The year parameter must be the desired year minus 1900. (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1)

  • toGMTString() This method is deprecated; use toUTCString() instead. Returns the string representation of the date relative to GMT. (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1)

  • toLocaleString() Returns the date converted to a string formatted according to local conventions as defined by the operating system. For example, the U.S. uses month/day/year whereas Europe uses day/month/year. The return value is not to be used for computation, but rather for display to the user. (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1)

  • toString() Returns the date as a string. (IE4+ (JScript 2.0+), MOZ, N3+ (JavaScript 1.1+), ECMA Edition 1)

  • toUTCString() Returns the date formatted as a string according to UTC. (IE4+ (JScript 3.0+), MOZ, N4.06+ (JavaScript 1.3+), ECMA Edition 1)

  • UTC(year, month, day [, hours [, mins [, secs [, ms]]]]) This static method returns a numeric value indicating the number of milliseconds between the epoch and the date given by the numeric parameters. Any parameters outside of their expected range cause the date to be adjusted accordingly. (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1)

  • valueOf() Returns a numeric value indicating the number of milliseconds difference between the date and the epoch. (IE4+ (JScript 2.0+), MOZ, N3+ (JavaScript 1.1+), ECMA Edition 1)

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:

  • cite String containing the URL of the reference for the modification. (IE6+, MOZ/N6+, DOM1)

  • dateTime String containing the date the modification was made. (IE6+, MOZ/N6+, DOM1)

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:

  • compact Boolean indicating whether the listing should be rendered compactly. (IE6+, MOZ/N6+, DOM1)

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:

  • align String specifying the alignment of the element. (IE4+, MOZ/N6+, DOM1)

  • dataFld String specifying which field of a data source is bound to the element. (IE4+)

  • dataFormatAs String indicating how the element treats data supplied to it. (IE4+)

  • dataSrc String containing the source of data for data binding. (IE4+)

  • noWrap Boolean indicating whether the browser should not carry out word wrapping. (IE4+)

Methods

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

  • doScroll([action]) Scrolls the top of the <div> block into view. If action is specified it must be one of several predetermined strings, such as "left" or "right", which give fine-grained control over scroll bar actions. See MSDN for complete details. (IE5+)

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:

  • compact Boolean value indicating whether the list should be compacted by removing extra space between list objects. (IE4+, MOZ/N6+, DOM1)

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

  • activeElement Reference to the object related to the element that currently has focus. This property is read-only. (IE4+)

  • alinkColor String containing the color of activated links. (IE3+, MOZ, N2+, DOM0)

  • anchors[] Collection of Anchor objects in the page (corresponds to <a name="...">...</a>). The collection is read-only, though the individual anchors can be modified and the DOM can be used to directly add or remove anchors that will ultimately affect the array’s contents. (IE3+, MOZ, N2+, DOM1)

  • applets[] Collection of Applet objects in the page (corresponds to <applet> elements). Like other document collections the individual objects can be manipulated, though the array itself is read-only. (IE4+, MOZ, N3+, DOM1)

  • bgColor String containing the background color of the document. (IE3+, MOZ, N2+, DOM0)

  • body Reference to the <body> or <frameset> element object of the document. (IE3+, MOZ/N6+, DOM1)

  • charset String containing the character set of the document. (IE4+)

  • characterSet String containing the character set of the document. (MOZ/N6+)

  • classes[] A Netscape 4–specific collection to access the style properties for CSS classes. (NS4 only)

  • compatMode Boolean indicating whether standards-compliant mode is on for the document. (IE6+)

  • cookie String holding the cookies the browser has for the domain of the document. Values set into this property are automatically parsed as cookies by the browser. (IE3+, MOZ, N2+, DOM1)

  • defaultCharset Read-only string containing the client’s default character set. (IE4+)

  • designMode String specifying whether design mode is on or off. When on, the user can double-click or otherwise activate an object and edit its HTML. (IE5+, MOZ/N7+)

  • dir String holding the text direction of text enclosed in the document. (IE5+, MOZ/N6+, DOM0)

  • doctype Reference to the DocumentType object for the document. (IE6+, MOZ/N6+, DOM1 Core)

  • documentElement Reference to the root node of the document object hierarchy. (IE5+, MOZ/N6+, DOM1 Core)

  • domain String containing the domain name from which the document was fetched. Can be set to a more general domain (e.g., www.javascriptref.com to javascriptref.com) in order to work around the same origin policy, but otherwise is not generally modifiable. (IE4+, MOZ, N3+, DOM1)

  • embeds[] Collection of all Embed objects in the document (corresponds to <embed> elements). Like other document collections the individual objects can be manipulated, though the array itself is read-only. (IE4+, MOZ, N3+)

  • expando Boolean dictating whether instance properties can be added to the object. (IE4+)

  • fgColor String containing the font color for the document. (IE3+, MOZ, N2+, DOM0)

  • fileCreatedDate Read-only string containing the date the document was created. (IE4+)

  • fileModifiedDate Read-only string containing the date the document was modified. (IE4+)

  • fileSize Read-only number (always an integer value) indicating the file size of the document in bytes. (IE4+)

  • forms[] Collection of Forms in the document (<form> elements). Like other document collections the individual objects can be manipulated, though the array itself is read-only. (IE3+, MOZ, N2+, DOM1)

  • frames[] Collection of Frames in the document (<frame> and <iframe> elements). Like other document collections the individual objects can be manipulated, though the array itself is read-only. (IE4+)

  • height Read-only property that holds the height in pixels of the document’s content, including the parts that might be scrolled offscreen. (MOZ, N4+)

  • ids[] A Netscape 4–specific collection that is used to access style properties set by an element’s id attribute. (NS4 only)

  • images[] Collection of Images in the document (<img> elements). Like other document collections the individual objects can be manipulated, though the array itself is read-only. (IE4+, MOZ, N3+, DOM1)

  • implementation Object with method hasFeature(feature, level) that returns a Boolean indicating if the browser supports the feature given in the string feature at the DOM level passed in the string level. Valid values for feature are CSS, Events, HTML, HTMLEvents, MouseEvents, Range, StyleSheets, Views, and XML. Valid values for level are DOM levels, for example, "1.0" or "2.0". The values returned by the method are often inaccurate because of spotty browser support for DOM functionality. (IE6+, MOZ/N6+, DOM1 Core)

  • lastModified A read-only string containing the date the document was last modified. (IE3+, MOZ, N2+, DOM0)

  • layers[] A Netscape 4–specific collection of Layers in the document (<layer> elements). Note that Netscape also places <div>s having CSS positioning in this array as well. (NS4 only)

  • linkColor String containing the color of links in the document. (IE3+, MOZ, N2+, DOM0)

  • links[] Collection of Links in the document (<a href="...">...</a> elements). Like other document collections the individual objects can be manipulated, though the array itself is read-only. (IE3+, MOZ, N2+, DOM1)

  • location A Location object containing the URL of the document. Should not be set. Use window.location instead. (IE2+, N3-4)

  • media String containing the media for which the document is intended. (IE5.5+)

  • mimeType A read-only string containing information about the type of the document (not usually a real MIME type!). (IE5+)

  • namespaces[] A read-only collection of XML namespace objects for the document. (IE5.5+)

  • parentWindow A read-only reference to the Window that contains the document. (IE4+)

  • plugins[] Collection of Plugin objects installed in the browser. In Internet Explorer, this is a synonym for the embeds[] collection. (IE4+, N4+)

  • protocol String containing the protocol used to retrieve the document (its full name, not "http"). (IE4+)

  • referrer A read-only string containing the URL of the referring document. If the page is directly loaded or not run off the server, referrer will not be set. (IE3+, MOZ, N2+, DOM1)

  • scripts[] A read-only collection of script objects in the document (<script> elements). Note you may be able to modify scripts and their contents but self-referencing script is generally not appropriate and should be used with caution. (IE4+)

  • security A read-only string containing information about the document’s certificate. (IE5.5+)

  • selection A read-only reference to the selection object representing the currently selected text. (IE4+)

  • styleSheets[] Collection of styleSheets in the document (<style> elements). Like other document collections the individual objects can be manipulated, though the array itself is read-only. (IE4+, MOZ/N6+)

  • tags[] A Netscape 4–specific collection to access style properties for particular HTML tags. (NS4 only)

  • title String containing the title of the object (the <title> content). (IE3+, MOZ, N2+, DOM1)

  • URL String containing the URL of the document; traditionally, an alias for location.href. (IE4+, MOZ, N2+)

  • URLUnencoded A read-only string holding the URL-unencoded version of the URL property. (IE5.5+)

  • vlinkColor String holding the color of visited links. (IE3+, MOZ, N2+, DOM0)

  • width A read-only property that holds the width of all the document’s content in pixels (including any parts that might be scrolled offscreen). (MOZ, N4+)

  • XMLDocument Reference to the top-level node of the XML Document Object Model exposed by the document. (IE5+)

  • XSLDocument A read-only reference to the XSL document object for the document. (IE5+)

Methods

  • captureEvents(eventMask) Instructs object to capture the events given in the bitmask eventMask. (MOZ, N4+)

  • clear() Supposedly clears the document of content but in reality crashes the browser or does nothing. This method should not be used. (IE3+, MOZ, N2+)

  • close() Closes output stream to the document and displays written content. (IE3+, MOZ, N2+, DOM1)

  • contextual(context1 [, context2, ...] style) A Netscape 4–specific method to select tags for style setting by concept. Rarely used and now deprecated. (N4 only)

  • createAttribute(name) Returns a new attribute node of a name given by string name. (IE6+, MOZ/N6+, DOM1 Core)

  • createCDATASection(data) Creates a CDATA section with value data. (MOZ/N6+, DOM1 Core)

  • createComment(data) Returns a new comment node with text content given by string data. (IE6+, MOZ/N6+, DOM1 Core)

  • createDocumentFragment() Creates a new, empty DocumentFragment. (MOZ/N6+, IE5+, DOM1 Core)

  • createElement(tagName) Returns a new element object corresponding to the string tagName (for example, "P"). In the case of HTML most implementations do not care about casing but developers should be aware of the case "p" versus "P" passed to the method. (IE4+, MOZ/N6+, DOM1 Core)

  • createEntityReference(name) Creates an XML entity with the given name. (MOZ/N7+, DOM1 Core)

  • createEventObject([eventObj]) Creates and returns a new Event instance to pass to fireEvent(). If the Event instance eventObj is supplied, its properties are cloned into the new event. Otherwise, they must be manually filled. (IE5.5+)

  • createProcessingInstruction(target, data) Creates an XML processor–specific instruction with the given target and data. (MOZ/N7+, DOM1 Core)

  • createStyleSheet([url [, index]]) Creates a new styleSheet object from the style sheet at the URL found in string url and inserts it into the document at index index. If url is omitted, an empty style sheet is added. If index is omitted, the new style sheet is placed at the end. (IE4+)

  • createTextNode(data) Returns a new text node with value given by the string data. (IE5+, MOZ/N6+, DOM1 Core)

  • elementFromPoint(x, y) Returns the element object found at the pixel location (x,y) in the document. (IE4+)

  • execCommand(command [, UIFlag][, parameter]) Permits all sorts of operations on the document related to the MSHTML editor. This could allow the creation of a browser-based HTML editor. See Microsoft documentation for details on this very proprietary technology. (IE4+)

  • focus() Gives focus to the document and causes its onfocus handler to fire. (IE5.5+)

  • getElementById(id) Returns the element with id equal to the string id or null if it does not exist. Some implementations may also find objects related to tags with the name attribute set, but this should not be assumed. (IE5+, MOZ/N6+, DOM1)

  • getElementsByName(name) Retrieves a collection of elements with name attributes equal to string name. In some browsers you will also find tags with id values set to name, however, given that tags should not share id values, this result should not be assumed. The method is meant to support form fields and other HTML elements that could share name attribute values under older HTML versions. (IE5+, MOZ/N6+, DOM1 Core)

  • getElementsByTagName(tagname) Retrieves a collection of elements corresponding to the tag given in string tagname. A value of "*" retrieves all tags. (IE5+, MOZ/N6+, DOM1)

  • getSelection() Returns any text currently selected by the user. (N4+)

  • isSupported(feature [, version]) Returns a Boolean indicating whether feature and version given in the argument strings are supported. (MOZ/N6+, DOM2)

  • open() Opens the document for writing, clearing it first if the document has content. Using this method is typically unnecessary. Internet Explorer implements a more complicated version of this method. (IE3+, MOZ, N2+, DOM1)

  • open([mimeType [,name] [, features] [, replace]]) Opens the document for writing. Using this method is usually unnecessary and when used it generally does not have parameters. However, when used the mimeType parameter is a string that specifies the type of data that will be written, name indicates the new name for the document (e.g., for link targets), features is a string indicating the window-like features the document should have, and replace is an optional Boolean that when true replaces the document in the browser’s history rather than creating a new entry. See MSDN for complete details. (IE3+)

  • queryCommandEnabled, queryCommandIndeterm, queryCommandState, queryCommandSupported, queryCommandValue These methods are related to the execCommand() method in Internet Explorer, which manipulates the MSHTML editor control. These methods indicate whether a command is allowed, enabled, and what its currents status is. See Microsoft documentation at MSDN for details on this very proprietary technology. (IE4+)

  • recalc([forceAll]) Forces reevaluation of dynamic properties in the document. If forceAll is true, then all dynamic properties are reevaluated (not just those that have changed). (IE5+)

  • releaseEvents(eventMask) Instructs object to stop capturing the events given in the bitmask eventMask. Only for the Netscape style of event capture. (N4+)

  • routeEvent(event) Passes the Event instance event along normally down the hierarchy. Used to decline to handle an event. Only for the Netscape style of event capture. (N4+)

  • selection Reference to the selection object containing information about the currently selected objects in the document. (IE4+)

  • write(str1 [, str2, ...]) Writes the text arguments to the document. (IE3+, MOZ, N2+, DOM1)

  • writeln(str1 [, str2, ...]) Writes the text arguments to the document followed by a newline at the end of the output. (IE3+, MOZ, N2+, DOM1)

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:

  • noWrap Boolean indicating whether the browser should not word wrap the item. (IE4+)

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).

  • height Integer specifying the height of the embedded object (default is in pixels). (IE4+, MOZ/N6+)

  • hidden Boolean indicating whether the object is hidden (invisible). (IE4+)

  • name String holding the name attribute of the element. (IE4+, MOZ/N6+)

  • palette Read-only string specifying the color palette to use for the object (for example, "foreground"). (IE4+ Windows)

  • pluginspage Read-only string specifying the URL of the page that contains information about the required plug-in, in case it is not installed. (IE4+, MOZ/N6+)

  • src String specifying the URL of the embedded object. (IE4+, MOZ/N6+)

  • type String specifying the MIME type of the object. (MOZ/N6+)

  • units String specifying the units ("em" or "px") for the height and width of the object. (IE4+)

  • width Specifies the width of the object (default is in pixels). (IE4+, MOZ/N6+)

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

  • atEnd() Returns a Boolean indicating if the current item is the last one in the collection. (IE4+)

  • item() Returns the current item or undefined if the collection is empty. (IE4+)

  • moveFirst() Resets the current item in the collection to the first item. (IE4+)

  • moveNext() Moves the current item to the next item in the collection. (IE4+)

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

  • constructor Reference to the constructor object that created the object. (IE5+ (JScript 5.0+), MOZ/N6+ (JavaScript 1.5+), ECMA Edition 3)

  • description String describing the nature of the exception or error. (IE5+ (JScript 5.0+))

  • fileName String indicating the URL of the document that threw the exception. (MOZ/N6+ (JavaScript 1.5+))

  • lineNumber The number of the line that generated the exception. (MOZ/N6+, (JavaScript 1.5+))

  • message String describing the nature of the exception or error. (IE5.5+ (JScript 5.5+), MOZ/N6+ (JavaScript 1.5+), ECMA Edition 3)

  • name String containing the type of the error, for example, "Error", "URIError", or "SyntaxError." (IE5.5+ (JScript 5.5+), MOZ/N6+ (JavaScript 1.5), ECMA Edition 3)

  • number Numeric value indicating the Microsoft-specific error number of the exception. Experimentation shows that this value very often deviates from Microsoft’s documentation, so it should be used with great caution. (IE5+ (JScript 5.0+))

  • stack String containing a stack trace. The trace gives execution information about the context in which the error was created. (MOZ/N6+)

  • prototype Reference to the object’s prototype. (IE5+ (JScript 5.0+), MOZ/N6+ (JavaScript 1.5+), ECMA Edition 3)

Methods

  • toString() Returns the error string corresponding to the error. (IE5+ (JScript 5.0+), MOZ/N6+ (JavaScript 1.5+), ECMA Edition 3)

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

  • ABORT, BLUR, CHANGE, CLICK, DBLCLICK, DRAGDROP, ERROR, FOCUS, KEYDOWN, KEYPRESS, KEYUP, LOAD, MOUSEDOWN, MOUSEMOVE, MOUSEOUT, MOUSEOVER, MOUSEUP, MOVE, RESET, RESIZE, SELECT, SUBMIT, UNLOAD Static bitmasks corresponding to each event for use with Netscape’s event capturing functions. (N4+)

  • ALT_MASK, CTRL_MASK, META_MASK, SHIFT_MASK Static bitmasks corresponding to each key. (N4+)

  • altKey Boolean indicating whether the ALT key was depressed during the event. (IE4+, MOZ/N6+, DOM2)

  • altLeft Boolean indicating if the left ALT key was depressed during the event. (IE5.5+ Windows only)

  • Banner Related Advanced Stream Redirector (ASX) functionality. See MSDN for details. (IE6+)

  • boundElements[] Provides data binding–related functionality. See MSDN documentation. (IE4+)

  • bookmarks[ ] Provides data binding related functionality. See MSDN documentation. (IE4+)

  • bubbles Boolean indicating if the event bubbles. (MOZ/N6+, DOM2)

  • button Integer indicating which mouse buttons were pressed during the event. In IE the values are 0 (no buttons), 1 (left button), 2 (right button), 3 (left and right), 4 (middle), 5 (left and middle), 6 (right and middle), or 7 (all three). Behavior will vary under IE in MacOS. In Netscape 6 the values are 1 (primary mouse button), 2 (middle button), or 3 (right button). (IE4+, MOZ/N6+, DOM2)

  • cancelable Boolean indicating if the event is cancelable. (MOZ/N6+, DOM2)

  • cancelBubble Boolean indicating whether the event should bubble any higher in the object hierarchy once the current handler is done executing. (IE4+, MOZ/N6+)

  • charCode ASCII value of the key pressed during keyboard-related events. (MOZ/N6+)

  • clientX The x coordinate in pixels of the mouse pointer position relative to the client area of the browser window. Does not factor in user scrolling in IE. Read-only in Netscape. (IE4+, MOZ/N6+, DOM2)

  • clientY The y coordinate in pixels of the mouse pointer position relative to the client area of the browser window. Does not factor in user scrolling in IE. Read-only in Netscape. (IE4+, MOZ/N6+, DOM2)

  • contentOverflow Read-only Boolean value indicating whether the document contains extra content after processing the current LayoutRect object. Only included for onlayoutcomplete events. (IE5.5+)

  • ctrlKey Boolean indicating whether the CTRL key was pressed during the event. Read-only in Netscape. (IE4+, MOZ/N6+, DOM2)

  • ctrlLeft Boolean indicating if the left CTRL key was depressed during the event. (IE5.5+ Windows only)

  • currentTarget Read-only reference to the element whose handler is currently processing the event. (MOZ/N6+, DOM2)

  • data Netscape 4–specific array of strings containing the URLs of objects that were dragged and dropped. (N4 Only)

  • dataFld Provides data binding–related functionality. See Microsoft documentation. (IE4+)

  • dataTransfer A dataTransfer object providing functionality for drag-and-drop events. (IE5+)

  • detail Indicates the number of times the mouse button was clicked (if at all). (MOZ/N6+, DOM2)

  • eventPhase A read-only numeric value indicating the current phase the event is in

  • (1 for capture, 2 for at its target, 3 for bubbling). (MOZ/N6+, DOM2)

  • fromElement Reference to the object from which activation or the mouse pointer is exiting. (IE4+)

  • keyCode Contains an integer representing the Unicode value of the key (for keyboard events). The value is ASCII in Netscape 6. It is also read-only in Netscape browsers. (IE4+, MOZ/N6+)

  • layerX This read-only property holds the horizontal position in pixels of the cursor relative to the layer in which the event occurred. If the event is resize, this value holds the width of the object. In Mozilla/Netscape 6+ this value is relative to the object according to which the target element of the event is positioned (for example, the <body>). (N4+, MOZ/N6+)

  • layerY This read-only property holds the vertical position in pixels of the cursor relative to the layer in which the event occurred. If the event is resize, this value holds the height of the object. In Mozilla/Netscape 6+ this value is relative to the object according to which the target element of the event is positioned (for example, the <body>). (N4+, MOZ/N6+)

  • metaKey Read-only Boolean value indicating if the meta key was pressed during the event. (MOZ/N6+, DOM2)

  • modifiers Netscape 4–specific read-only bitmask indicating which modifier keys were held down during the event. The bitmask is a bitwise combination of the static properties ALT_MASK, CONTROL_MASK, META_MASK, and SHIFT_MASK. (N4 Only)

  • nextPage Provides print template–related functionality. See Microsoft documentation. (IE5.5+)

  • offsetX The x coordinate in pixels of the mouse with respect to the target object of the event. (IE4+)

  • offsetY The y coordinate in pixels of the mouse with respect to the target object of the event. (IE4+)

  • originalTarget Reference to the original target of the event. (MOZ/N6+)

  • pageX A read-only property containing the horizontal position in pixels where the event occurred with respect to the page. (N4+, MOZ/N6+)

  • pageY A read-only property containing the vertical position in pixels where the event occurred with respect to the page. (N4+, MOZ/N6+)

  • propertyName String containing the name of the property that fired an onpropertychange event. (IE5+)

  • qualifier Provides data binding–related functionality. See Microsoft documentation. (IE4+)

  • reason Provides data binding–related functionality. See Microsoft documentation. (IE4+)

  • recordset Provides data binding–related functionality. See Microsoft documentation. (IE4+)

  • relatedTarget Reference to the node related to the event. For example, on a mouseover it references the node the mouse left; on mouseout it references the node the mouse moved to. The property is read-only. (MOZ/N6+, DOM2)

  • repeat Boolean indicating whether the key is continually repeating during onkeydown events. (IE5+)

  • returnValue Boolean dictating the return value of the event handler (takes precedence over return statements). (IE4+)

  • saveType String holding the clipboard type ("HTML" or "TEXT") during an oncontentsave. (IE5.5+)

  • screenX Horizontal position in pixels where the event occurred with respect to the whole screen. The property is read-only under Netscape browsers. (N4+, MOZ, IE4+, DOM2, ReadOnly in Netscape)

  • screenY Vertical position in pixels where the event occurred with respect to the whole screen. The property is read-only under Netscape browsers. (N4+, MOZ, IE4+, DOM2)

  • shiftKey Boolean indicating whether the SHIFT key was depressed during the event. The property is read-only under Netscape browsers. (IE4+, MOZ/N6+, DOM2)

  • shiftLeft Boolean indicating if the left SHIFT key was depressed during the event. (IE5.5+ Windows only)

  • srcElement Reference to the element object that is the target of the event. (IE4+)

  • srcFilter String containing the name of the CSS Filter that caused the onfilterevent to fire. (IE4+ but watch out for filter implementation changes in later versions)

  • srcUrn String containing the URN of the DHTML Behavior that fired the event. (IE5+)

  • target Read-only reference to the object at which the event occurred. (N4+, Moz, DOM2)

  • timeStamp A read-only property containing the time the event occurred, in milliseconds since the epoch. (MOZ/N6+, DOM2)

  • toElement Reference to the object toward which the user is moving the mouse (for example, during onmouseout). (IE4+)

  • type String containing the event type (for example, "click"). The property is read-only in Netscape. (N4+, MOZ, IE4+, DOM2)

  • view A read-only reference to the window or frame that encloses the object at which the event occurs. (MOZ/N6+, DOM2)

  • wheelDelta A read-only numeric value that is always an integer that is a multiple of 120. This value indicates how far the mouse wheel rotated, causing the event. Positive values indicate rotation away from the user, negative values toward the user. (IE5.5+)

  • which A read-only property that is used for mouse events and contains a numeric value indicating which mouse button was used (1 is left, 2 middle, 3 right) or for keyboard events, the Unicode (numeric) value of the key pressed. (N4+, MOZ)

  • x Same as layerX in Netscape. In IE, the x coordinate in pixels of the mouse pointer relative to the target element’s parent. This property is read-only in Netscape 4. (N4, IE4+)

  • y Same as layerY. In IE, the y coordinate in pixels of the mouse pointer relative to the target element’s parent. This property is read-only in Netscape 4. (N4, IE4+)

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).

  • onblur Fires when an element loses focus, meaning that the user has moved focus to another element, typically either by clicking or tabbing away. In IE4+ does not bubble and is not cancelable.

  • onchange Fires when a form field loses focus and its value was changed while it had focus. In IE4+ does not bubble but is cancelable.

  • onclick Fires when an element is clicked. In IE4+ bubbles and is cancelable.

  • ondblclick Fires when an element is double-clicked. In IE4+ bubbles and is cancelable.

  • onfocus Fires when an element receives focus, typically when it has been selected for manipulation or data entry by a click or tab. In IE4+ does not bubble and is not cancelable.

  • onkeydown Fires when the user presses a key and the element has focus. In IE4+ bubbles and is cancelable.

  • onkeypress Fires when the user presses or holds down a key (an alphanumeric key in Internet Explorer) and the element has focus. In IE4+ bubbles and is cancelable.

  • onkeyup Fires when the user releases a key and the element has focus. In IE4+ bubbles but is not cancelable.

  • onload Fires when the element has completed loading. In IE4+ does not bubble and is not cancelable.

  • onmousedown Fires when the mouse button is pressed and the element has focus. In IE4+ bubbles and is cancelable.

  • onmousemove Fires when the mouse is moved and the cursor is over the element. In IE4+ bubbles but is not cancelable.

  • onmouseout Fires when the user moves the mouse away from the element. In IE4+ bubbles but is not cancelable.

  • onmouseover Fires when the user moves the mouse over the element. In IE4+ bubbles and is cancelable.

  • onmouseup Fires when the mouse button is released and the element has focus. In IE4+ bubbles and is cancelable.

  • onreset Fires when the form is reset, often the result of the user pressing a Reset button. In IE4+ does not bubble but is cancelable.

  • onselect Fires when text or other content is selected by the user, typically by highlighting text with the mouse. In IE4+ does not bubble but is cancelable.

  • onsubmit Fires just prior to the submission of the form. In IE4+ does not bubble but is cancelable.

  • onunload Fires just prior to the unloading of the object (for example, when following a link to another page). In IE4+ does not bubble and is not cancelable.

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.

  • onabort Fires when the loading of the element is canceled before completion.

  • ondragdrop Fires when something has been dragged onto the object and dropped.

  • onerror Fires when a runtime error occurs at the element.

  • onmove Fires when the user or a script moves the window or frame (Netscape 4 only).

  • onpaint The meaning of this handler is unclear. Possibly related to XUL functionality (Netscape 6+/Moz only).

  • onresize Fires when the object is about to be resized (for example, just after the user has resized the window).

  • onscroll Fires when a scrollable object has been repositioned (Netscape 6 only).

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).

  • onabort Fires when the loading of the object is canceled before completion. In IE4+ does not bubble but is cancelable.

  • onactivate Fires when the object is set as the active element. In IE4+ bubbles but is not cancelable.

  • onafterprint Fires immediately after the object is printed (or previewed). In IE4+ does not bubble and is not cancelable.

  • onafterupdate Fires on a databound object after successfully updating the associated data in the data source object. In IE4+ bubbles but is not cancelable.

  • onbeforeactivate Fires immediately before the object is set as the active element. In IE4+ bubbles and is cancelable.

  • onbeforecopy Fires on the source object just before the selection is copied to the system clipboard. In IE4+ bubbles and is cancelable.

  • onbeforecut Fires on the source object before the selection is cut from the document to the clipboard (or deleted from the document). In IE4+ bubbles and is cancelable.

  • onbeforedeactivate Fires immediately before the activeElement is changed from the current object to another object in the parent document. In IE4+ bubbles and is cancelable.

  • onbeforeeditfocus Fires before the element receives focus for editing. In IE4+ bubbles and is cancelable.

  • onbeforepaste Fires on the target object before the selection is pasted from the system clipboard. In IE4+ bubbles and is cancelable.

  • onbeforeprint Fires on the object before its associated document prints or previews for printing. In IE4+ does not bubble and is not cancelable.

  • onbeforeunload Fires prior to a page being unloaded (just before the unload handler). In IE4+ does not bubble but is cancelable.

  • onbeforeupdate Fires on a databound object just before updating the associated data in the data source object. In IE4+ bubbles and is cancelable.

  • onbounce Fires on an alternating <marquee> just prior to the contents reaching one side of the window. In IE4+ does not bubble but is cancelable.

  • oncellchange Fires when data changes in the data provider. In IE4+ bubbles but is not cancelable.

  • oncontextmenu Fires when the user clicks the right mouse button on the object, opening the context menu. In IE4+ bubbles and is cancelable.

  • oncontrolselect Fires just prior to the object being selected. In IE4+ bubbles and is cancelable.

  • oncopy Fires on the object when the user copies it (or a selection that includes it) to the system clipboard. In IE4+ bubbles and is cancelable.

  • oncut Fires on the object when the user cuts it (or a selection that includes it) to the system clipboard. In IE4+ bubbles and is cancelable.

  • ondataavailable Fires when data arrives from asynchronous data source objects. In IE4+ bubbles but is not cancelable.

  • ondatasetchanged Fires when the data set exposed by a data source object changes. In IE4+ bubbles but is not cancelable.

  • ondatasetcomplete Fires to indicate that all data is available from the data source object. In IE4+ bubbles but is not cancelable.

  • ondeactivate Fires when the activeElement is changed from the current object to another object in the parent document. In IE4+ bubbles but is not cancelable.

  • ondrag Fires on an object continuously as it is being dragged. In IE4+ bubbles and is cancelable.

  • ondragend Fires on an object being dragged when the object is released at the end of a drag operation. In IE4+ bubbles and is cancelable.

  • ondragenter Fires on an object that is a valid drop target as the user drags an object into it. In IE4+ bubbles and is cancelable.

  • ondragleave Fires on an object that is a valid drop target as the user drags an object out of it. In IE4+ bubbles and is cancelable.

  • ondragover Fires on an object that is a valid drop target continuously as the user drags an object over it. In IE4+ bubbles and is cancelable.

  • ondragstart Fires on the object about to be dragged when the user begins a drag operation. In IE4+ bubbles and is cancelable.

  • ondrop Fires on an object when something is dropped on it at the end of a drag operation. In IE4+ bubbles and is cancelable.

  • onerror Fires when a runtime error occurs in or at the object. In IE4+ does not bubble but is cancelable.

  • onerrorupdate Fires on a databound object when an error occurs while updating the associated data in the data source object. In IE4+ bubbles but is not cancelable.

  • onfilterchange Fires when a the object’s CSS Filter changes state or completes a transition. In IE4+ does not bubble and is not cancelable.

  • onfinish Fires on a <marquee> when looping is complete. In IE4+ does not bubble but is cancelable.

  • onfocusin Fires on an element just prior to it receiving focus (before the focus event). In IE4+ bubbles but is not cancelable.

  • onfocusout Fires for the current element with focus, immediately after moving focus to another element. In IE4+ bubbles but is not cancelable.

  • onhelp Fires when the user presses the F1 key while the browser is the active window. In IE4+ bubbles and is cancelable.

  • onlayoutcomplete Fires when the print or print preview layout process finishes filling the current LayoutRect object with content from the source document. In IE4+ bubbles and is cancelable.

  • onlosecapture Fires when the object loses universal mouse capture. In IE4+ does not bubble and is not cancelable.

  • onmouseenter Fires when the user moves the mouse pointer into the object. (Different from onmouseover because the mouseenter event does not bubble.) In IE4+ does not bubble and is not cancelable.

  • onmouseleave Fires when the user moves the mouse pointer outside the boundaries of the object. (Different from onmouseout because the mouseleave event does not bubble.) In IE4+ does not bubble and is not cancelable.

  • onmousewheel Fires when the mouse wheel button is rotated. In IE4+ bubbles and is cancelable.

  • onmove Fires when the object moves. In IE4+ bubbles but is not cancelable.

  • onmoveend Fires when the object stops moving. In IE4+ bubbles but is not cancelable.

  • onmovestart Fires just prior to the object starting to move. In IE4+ bubbles and is cancelable.

  • onpaste Fires on the object into which the user is pasting data from the clipboard.

  • In IE4+ bubbles and is cancelable.

  • onpropertychange Fires when a property of the object changes. In IE4+ does not bubble and is not cancelable.

  • onreadystatechange Fires when the readyState of the object changes. In IE4+ does not bubble and is not cancelable.

  • onresize Fires when the size of the object is about to change (for example, just after the user has resized the window). In IE4+ does not bubble and is not cancelable.

  • onresizeend Fires when the user finishes changing the dimensions of the object in a selection. In IE4+ does not bubble and is not cancelable.

  • onresizestart Fires when the user begins to change the dimensions of the object in a selection. In IE4+ does not bubble but is cancelable.

  • onrowenter Fires to indicate that the current row has changed in the data source and new data values are available on the object. In IE4+ bubbles but is not cancelable.

  • onrowexit Fires just before the data source control changes the current row in the object. In IE4+ does not bubble but is cancelable.

  • onrowsdelete Fires when rows are about to be deleted from the recordset. In IE4+ bubbles but is not cancelable.

  • onrowsinserted Fires just after new rows are inserted in the current recordset. In IE4+ bubbles but is not cancelable.

  • onscroll Fires on a scrollable object when the user repositions the scroll box on the scroll bar. In IE4+ does not bubble and is not cancelable.

  • onselectionchange Fires whenever the selection state of a document changes. In IE4+ does not bubble and is not cancelable.

  • onselectstart Fires when the object is being selected. In IE4+ bubbles and is cancelable.

  • onstart Fires on <marquee> elements at the beginning of every loop. In IE4+ does not bubble and is not cancelable.

  • onstop Fires when the user clicks the Stop button or leaves the Web page. In IE4+ does not bubble and is not cancelable.

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

  • menuArguments Returns the window object where the context menu item was executed. (IE4+)

Methods

  • AddChannel(url) Presents a dialog box to allow a user to add or change a channel. The parameter url references a Channel Definition Format (CDF) file. Internet Explorer’s push channel technology is rarely used now.

  • AddDesktopComponent(url, type [, left] [, top] [, width] [, height]) Adds a Web site or image as defined by url to the Active Desktop. The type attribute is set either to "image" or "website" and the optional parameters indicate the position and size of the component to add.

  • AddFavorite(url) Prompts user to add a specified URL to their favorites.

  • AutoCompleteSaveForm(form) Saves the data in the passed form object to IE’s auto form completion system. (IE5+)

  • AutoScan(query, errorURL [, target]) Attempts to load the query value using IE’s standard URL expansion. For example a query of "microsoft" would be translated to www.microsoft.com. If the site cannot be connected the errorURL should be displayed instead; otherwise, the browser uses a default error page. The optional target parameter is used to specify the window or frame to load the page into. (IE5+)

  • ImportExportFavorites(importExport,url) Allows the importing and exporting of brower favorites or bookmarks. A value of true for importExport indicates importing while false indicates exporting. The url parameter indicates the path or URL to export from or import to. The user will be prompted to allow this activity.

  • IsSubcribed(url) Returns a Boolean value indicating if the user is subscribed to the channel defined by the CDF file referenced by the passed url parameter.

  • NavigateAndFind(url,searchText,target) Navigates to the specified url and finds and highlights the passed searchText. The target value should be set if this is to be performed in another frame or window.

  • ShowBrowserUI(type,null) Opens a browser-related dialog of a defined type. Allowed values for type include "LanguageDialog", "OrganizeFavorites", "PrivacySettings", and "ProgramAccessAndDefaults". The second null value parameter is strangely required. PrivacySettings is only supported in IE6 or later and ProgramAccessAndDefaults requires Windows XP SP1 or later. (IE5+)

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:

  • form Reference to the Form in which the element is contained. (IE6+, MOZ/N6+, DOM1)

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:

  • accept String containing a comma-separated list of MIME types the server will accept for this file upload. (MOZ/N6+, DOM1)

  • accessKey Single-character string indicating the hotkey that gives the element focus. (IE4+, MOZ/N6+, DOM1)

  • defaultValue String containing the original value of the value attribute. (IE4+)

  • disabled Boolean indicating whether the element is disabled (grayed out). (IE4+, MOZ/N6+, DOM1)

  • form Read-only reference to the Form in which the button is contained. (IE4+, MOZ, N3+, DOM1)

  • name String holding the name attribute of the element. (IE4+, MOZ, N3+, DOM1)

  • size String indicating the width in pixels. (IE4+, MOZ/N6+, DOM1)

  • tabIndex Numeric value indicating the tab order for the object. (IE4+, MOZ/N6+, DOM1)

  • type Read-only string value indicating the type of the field, "file". (IE4+, MOZ, N3+, DOM1)

  • value Read-only string containing the filename. (IE4+, MOZ, N3+, DOM1)

  • width The width in pixels of the input area. (IE4+)

Methods

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

  • blur() Causes the button to lose focus. (IE4+, MOZ, N3+, DOM1)

  • focus() Gives the button focus. (IE4+, MOZ, N3+, DOM1)

  • handleEvent(event) Causes the Event instance event to be processed by the appropriate handler of the object. (N4 only)

  • select() Selects the text entered as input (the filename). (IE4+, MOZ/N6+, DOM1)

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:

  • color String holding the default text color for the page. (IE4+, MOZ/N6+, DOM1)

  • face String holding a comma-separated list of one or more default font names. (IE4+, MOZ/N6+, DOM1)

  • size String holding the default font size (HTML 1–7 or relative +n/–n syntax). (IE3+, MOZ/N6+, DOM1)

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:

  • acceptCharset String specifying a list of character encodings for input data that will be accepted by the server processing the form. (IE5+, MOZ/N6+, DOM1)

  • action String containing the URL to which the form will be submitted. (IE3+, MOZ, N2+, DOM1)

  • autocomplete String specifying whether IE’s specific form auto-completion is "on" or "off". (IE5+)

  • elements[] A read-only collection, in source order, of all fields (controls) in the form. (IE3+, MOZ, N2+, DOM1)

  • encoding String specifying the MIME type of submitted form data. (IE3+, MOZ, N2+)

  • enctype String specifying the MIME type of submitted form data. (MOZ/N6+, IE6+, DOM1)

  • length The number of entries in the elements[] collection (the number of fields of the form). The property is read-only, though its value may change if the DOM is used to add or delete elements in the form. (IE3+, MOZ, N2+, DOM1)

  • method String indicating the HTTP method used to submit the form data, either "get" or "post". (IE3+, MOZ, N2+, DOM1)

  • name String holding the name attribute of the form. (IE3+, MOZ, N2+, DOM1)

  • target String indicating the name of the window or frame in which the results of the form submission should be shown. (IE3+, MOZ, N2+, DOM1)

Methods

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

  • reset() Resets all form fields to their original values. (IE4+, MOZ, N3+, DOM1)

  • submit() Causes form submission to occur. (IE3+, MOZ, N2+, DOM1)

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:

  • allowTransparency Boolean specifying whether the background of the frame can be transparent (can be set to any color). (IE5.5+)

  • borderColor String specifying the color of the border around the frame. (IE4+)

  • contentDocument Read-only reference to the Document that corresponds to the content of this frame. (MOZ/N6+)

  • contentWindow Read-only reference to the Window that corresponds to this frame. (IE5.5+, MOZ/N6+)

  • dataFld String specifying which field of a data source is bound to the element. (IE4+)

  • dataSrc String containing the source of data for data binding. (IE4+)

  • frameBorder String containing "0" (no border) or "1" (show border). (IE4+, MOZ/N6+, DOM1)

  • height Height of the frame in pixels. (IE5.5+)

  • longDesc String containing the URI of a long description for the frame (for nonvisual browsers). (IE6+, MOZ/N6+, DOM1)

  • marginHeight String specifying the vertical margins, in pixels. Overridden by CSS properties. (IE4+, MOZ/N6+, DOM1)

  • marginWidth String specifying the horizontal margins, in pixels. Overridden by CSS properties. (IE4+, MOZ/N6+, DOM1)

  • name String holding the name attribute of the frame. (IE4+, MOZ/N6+, DOM1)

  • noResize Boolean indicating whether the user cannot resize the frame. (IE4+, MOZ/N6+, DOM1)

  • scrolling String specifying whether the frame should have scroll bars, either "yes", "no", or "auto". (IE4+, MOZ/N6+, DOM1)

  • src String giving the URL of the frame’s contents. (IE4+, MOZ/N6+, DOM1)

  • width Width of the frame’s content area in pixels. (IE5.5+)

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:

  • border String indicating the number of pixels to use for the border between frames. (IE4+)

  • borderColor String indicating the color (should be in #RRGGBB hex) of the border. (IE4+)

  • cols Comma-separated string of column widths for the frames. This string is composed of pixel values, percentage values, and * values. (IE4+, MOZ/N6+, DOM1)

  • frameBorder String specifying whether to show borders around the frames ("1" for yes, "0" for no). (IE4+)

  • frameSpacing String indicating the number of pixels apart to place the frames. (IE4+)

  • height Height of the frameset in pixels or as a percentage. (IE4+)

  • name String holding the name attribute of the element. (IE4+, MOZ/N6+)

  • rows Comma-separated string of row heights for the frames. This string is composed of pixel values, percentage values, and * values. (IE4+, MOZ/N6+, DOM1)

  • width Width of the frameset in pixels or as a percentage. (IE4+)

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

  • arguments[] An implicitly filled and implicitly available (directly usable as "arguments" from within the function) array of parameters that were passed to the function. This value is null if the function is not currently executing. (IE4+ (JScript 2.0+), MOZ, N3+ (JavaScript 1.1+), ECMA Edition 1)

  • arguments.callee Reference to the current function. This property is deprecated. (N4+, MOZ, IE5.5+)

  • arguments.caller Reference to the function that invoked the current function. This property is deprecated. (N3, IE4+)

  • arguments.length The number of arguments that were passed to the function. (IE4+ (JScript 2.0+), MOZ, N3+ (JavaScript 1.1+), ECMA Edition 1)

  • arity Numeric value indicating how many arguments the function expects. This property is deprecated. (N4+, MOZ)

  • caller Reference to the function that invoked the current function or null if called from the global context. (IE4+ (JScript 2.0+), MOZ, N3+)

  • constructor Reference to the constructor object that created the object. (IE4+ (JScript 2.0+), N3+ (JavaScript 1.1+), ECMA Edition 1)

  • length The number of arguments the function expects to be passed. (IE4+ (JScript 2.0+), N3+ (JavaScript 1.1+), ECMA Edition 1)

  • prototype Reference to the object’s prototype. (IE4+ (JScript 2.0+), N3+ (JavaScript 1.1+), ECMA Edition 1)

Methods

  • apply(thisArg [, argArray]) Invokes the function with the object referenced by thisArg as its context (so references to this in the function reference thisArg). The optional parameter argArray contains the list of parameters to pass to the function as it is invoked. (IE5.5+ (JScript 5.5+), N4.06+ (JavaScript 1.3+), MOZ, ECMA Edition 3)

  • call(thisArg [, arg1 [, arg2 [, ...]]]) Invokes the function with the object referenced by thisArg as its context (so references to this in the function reference thisArg). The optional parameters argN are passed to the function as it is invoked. (IE5.5+ (JScript 5.5+), N4.06+ (JavaScript 1.3+), MOZ, ECMA Edition 3)

  • toString() Returns the string version of the function source. The body of built-in and browser objects will typically be represented by the value "[native code]". (IE4+ (JScript 2.0+), N3+ (JavaScript 1.1+), MOZ, ECMA Edition 1)

  • valueOf() Returns the string version of the function source. The body of built-in and browser objects will typically be represented by the value "[native code]". (IE4+ (JScript 2.0+), N3+ (JavaScript 1.1+), MOZ, ECMA Edition 1)

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

  • Infinity Constant holding the numeric value Infinity. (IE4+ (JScript 3.0+), N4.06+ (JavaScript 1.3+), MOZ, ECMA Edition 1)

  • NaN Constant holding the numeric value NaN (not a number). (IE4+ (JScript 3.0+), N4.06+ (JavaScript 1.3+), MOZ, ECMA Edition 1)

  • undefined Constant holding the value undefined. (IE5.5+ (JScript 5.5+), N4.06+ (JavaScript 1.3+), MOZ, ECMA Edition 1)

Methods

  • decodeURI(encodedURI) URI-decodes the string encodedURI and returns the decoded string. (IE5.5+ (JScript 5.5+), MOZ/N6+ (JavaScript 1.5+), ECMA Edition 3)

  • decodeURIComponent(encodedURI) URI-decodes the string encodedURI and returns the decoded string. (IE5.5+ (JScript 5.5+), MOZ/N6+ (JavaScript 1.5+), ECMA Edition 3)

  • encodeURI(uri) URI-encodes the string uri, treating uri as a full URI. Legal URI characters (for example, the :// after the protocol) are not encoded. Returns the encoded string. (IE5.5+ (JScript 5.5+), MOZ/N6+ (JavaScript 1.5+), ECMA Edition 3)

  • encodeURIComponent(uriComponent) URI-encodes the string uriComponent and returns the encoded string. All potentially problematic characters (for example, / and ?) are encoded. (IE5.5+ (JScript 5.5+), MOZ/N6+ (JavaScript 1.5+), ECMA Edition 3)

  • escape(string) URI-encodes string and returns the encoded string. Using the newer encodeURIComponent() is preferable. (IE3+ (JScript 1.0+), N2+ (JavaScript 1.0+), MOZ)

  • eval(string) Executes string as JavaScript. (IE3+ (JScript 1.0+), N2+ (JavaScript 1.0+), MOZ, ECMA Edition 1)

  • isFinite(value) Returns a Boolean indicating if the numeric argument value is finite. Returns false if value is NaN. (IE4+ (JScript 3.0+), N4.06+ (JavaScript 1.3+), MOZ, ECMA Edition 1)

  • isNaN(value) Returns a Boolean indicating if the numeric argument value is NaN. (IE4+ (JScript 3.0+), N3+ (JavaScript 1.1+), MOZ, ECMA Edition 1)

  • parseFloat(string) Parses string as a floating-point number and returns its value. If string cannot be converted, NaN is returned. (IE3+ (JScript 1.0+), N2+ (JavaScript 1.0+), MOZ, ECMA Edition 1)

  • parseInt(string) Parses string as an integer and returns its value. If string cannot be converted, NaN is returned. (IE3+ (JScript 1.0+), N2+ (JavaScript 1.0+), MOZ, ECMA Edition 1)

  • unescape(encodedString) URI-decodes encodedString and returns the decoded string. Using the newer decodeURIComponent() method is preferable. (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+))

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:

  • profile String containing a whitespace-separated list of URIs giving data properties and legal values. (IE6+, MOZ/N6+, DOM1)

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 nth URL in the browser’s history.

Properties

  • current A read-only property that contains current URL in the history, requires UniversalBrowserRead privilege for access. (N3+, MOZ)

  • length A read-only property containing the number of entries in the history list. (IE3+, MOZ, N2+)

  • next A read-only property that contains the next URL in the history, requires UniversalBrowserRead privilege for access. (N3+, MOZ)

  • previous A read-only property that contains the previous URL in the history, requires UniversalBrowserRead privilege for access. (N3+, MOZ)

Methods

  • back() Causes the browser to move one URL back in its history. (IE3+, N2+, MOZ)

  • forward() Causes the browser to move one URL forward in its history. (IE3+, N2+, MOZ)

  • go(where) If where is an integer, loads the URL at that offset from the current page in the history. For example, go(–2) moves back two steps in the history. If where is a string, the first entry in the history list containing where in its URL or document title is loaded. (IE3+, N2+, MOZ)

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 <hn> (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:

  • align String specifying the alignment of the element, for example, "left". (IE4+, MOZ/N6+, DOM1)

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:

  • align String specifying the alignment of the element, for example, "left". (IE4+, MOZ/N6+, DOM1)

  • color String specifying the color of the rule. (IE4+)

  • noShade Boolean indicating that the rule is not to be shaded. (IE4+, MOZ/N6+, DOM1)

  • size String specifying the size (height) of the rule in pixels. (IE4+, MOZ/N6+, DOM1)

  • width String specifying the width of the rule in pixels. (IE4+, MOZ/N6+, DOM1)

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:

  • scroll String indicating whether scroll bars should be present in the document. Valid values are "yes", "no", and "auto". (IE6+)

  • version String containing the DTD version for the document. (IE6+, MOZ/N6+, DOM1)

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:

  • align String specifying the alignment of the element, for example, "left". (IE4+, MOZ/N6+, DOM1)

  • allowTransparency Boolean specifying whether the background of the frame can be transparent (can be set to any color). (IE5.5+)

  • border String or integer indicating the width of the border around the frame. (IE4+)

  • contentDocument Read-only reference to the Document that corresponds to the content of this frame. (MOZ/N6+)

  • contentWindow Read-only reference to the Window that corresponds to this frame. (IE5.5+, MOZ/N6+)

  • dataFld String specifying which field of a data source is bound to the element. (IE4+)

  • dataSrc String containing the source of data for data binding. (IE4+)

  • frameBorder String containing "0" (no border) or "1" (show border). (IE4+, MOZ/N6+, DOM1)

  • height String specifying the height of the frame in pixels. (IE4+, MOZ/N6+, DOM1)

  • hspace String indicating the horizontal margin for the frame in pixels. (IE4+)

  • longDesc String containing the URL of a long description for the frame similar to "alt text" and used for nonvisual browsers. (IE6+, MOZ/N6+, DOM1)

  • marginHeight String specifying the vertical margins, in pixels. Overridden by CSS properties. (IE4+, MOZ/N6+, DOM1)

  • marginWidth String specifying the horizontal margins, in pixels. Overridden by CSS properties. (IE4+, MOZ/N6+, DOM1)

  • name String holding the name attribute of the frame. (IE4+, MOZ/N6+, DOM1)

  • scrolling String specifying whether the frame should have scroll bars. Its value is either "yes", "no", or "auto". (IE4+, MOZ/N6+, DOM1)

  • src String giving the URL of the frame’s contents. (IE4+, MOZ/N6+, DOM1)

  • vspace String indicating the vertical margin for the frame in pixels. (IE4+)

  • width String specifying the width of the frame in pixels. (IE4+, MOZ/N6+, DOM1)

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:

  • align String specifying the alignment of the element, for example, "left". (IE4+, MOZ/N6+, DOM1)

  • alt String containing the alternative text for the image. Corresponds to the alt attribute of the <img>. (IE4+, MOZ/N6+, DOM1)

  • border Numeric value indicating the border width in pixels of the image. The property is read-only under early versions of Netscape. (IE4+, N3+, MOZ, DOM1)

  • complete Read-only Boolean indicating whether the image has finished loading. (IE4+, N3+, MOZ)

  • dataFld String specifying which field of a data source is bound to the element. (IE4+)

  • dataSrc String containing the source of data for data binding. (IE4+)

  • dynsrc String indicating the URL of the video clip to display instead of a static image. (IE4+)

  • fileCreatedDate Read-only string containing the date the image was created if it can be determined, or the empty string otherwise. (IE4+)

  • fileModifiedDate Read-only string containing the date the image was last modified if it can be determined, or the empty string otherwise. (IE4+)

  • fileSize Read-only value indicating the size in bytes of the image (if it can be determined). (IE4+)

  • fileUpdatedDate Read-only string containing the date the image was last updated if it can be determined, or the empty string otherwise. (IE4+)

  • galleryImg String indicating whether IE’s Image Toolbar is visible ("yes") or invisible ("no"). (IE6+)

  • height Specifies the height in pixels of the image. Read-only in Netscape 3 and 4. (IE4+, N3+, MOZ, DOM1)

  • hspace Specifies the horizontal margin for the image in pixels. Read-only in Netscape 3 and 4. (IE4+, N3+, MOZ, DOM1)

  • isMap Boolean indicating if the image is a server-side image map. (IE4+, MOZ/N6+, DOM1)

  • longDesc String specifying a URL for a longer description of the image. (IE6+, MOZ/N6+, DOM1)

  • loop Integer indicating the number of times the image is to loop when activated. (IE4+)

  • lowSrc String specifying a URL for a lower-resolution image to display. (DOM1, though support may be inconsistent in browsers)

  • lowsrc String specifying a URL for a lower-resolution image to display. (IE4+, N3+, MOZ)

  • name String holding the name attribute of the element. Read-only in Netscape 3 and 4. (IE4+, N3+, MOZ, DOM1)

  • nameProp Read-only string indicating the name of the file given in the src attribute of the <img>. Does not include protocol, domain, directory, or other information. (IE5+)

  • protocol Read-only string containing the full name of the protocol portion of the URL of the src attribute of the <img>. (IE4+)

  • src String containing the URL of the image. (IE4+, N3+, MOZ, DOM1)

  • start String indicating when the video associated with the image with the dynsrc property/attribute should begin playing. Values are "fileopen", the default, which begins playback when the file loads, or "mouseover", which begins when the user mouses over it. (IE4+)

  • useMap String containing URL to use as a client-side image map. (IE4+, MOZ/N6+, DOM1)

  • vspace Specifies the vertical margin for the image in pixels. Read-only in Netscape 3 and 4. (IE4+, N3+, MOZ, DOM1)

  • width Specifies the width of the object in pixels. Read-only in Netscape 3 and 4. (IE4+, N3+, MOZ, DOM1)

Methods

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

  • handleEvent(event) Causes the Event instance passed to be processed by the appropriate handler of the layer. (N4 only)

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

  • hasFeature(feature [, version]) Returns a Boolean indicating if the browser supports the feature specified by the string feature at the DOM level given in string level. Valid values for feature are CSS, Events, HTML, HTMLEvents, MouseEvents, Range, StyleSheets, Views, and XML. Valid values for level are DOM levels, for example, "1.0" or "2.0". The values returned by the method are often inaccurate because of spotty browser support for DOM functionality. (IE6+, MOZ/N6+, DOM1)

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:

  • cite String containing the URL of the reference for the modification. (IE6+, MOZ/N6+ DOM1)

  • dateTime String containing the date the modification was made. (IE6+, MOZ/N6+, DOM1)

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:

  • form A read-only reference to the Form object that contains this tag.

  • prompt A string value that holds the prompt message defined by the prompt attribute for that tag.

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:

  • accessKey Single character string indicating the hotkey that gives the element focus. (IE4+, MOZ/N6+, DOM1)

  • dataFld String specifying which field of a data source is bound to the element. (IE4+)

  • dataFormatAs String indicating how the element treats data supplied to it. (IE4+)

  • dataSrc String containing the source of data for data binding. (IE4+)

  • form Reference to the Form the label is enclosed within. (IE4+, MOZ/N6+, DOM1)

  • htmlFor String containing the identifier of the object the label is for. (IE4+, MOZ/N6+, DOM1)

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

  • above Reference to the Layer above the current layer according to the z-index order among all layers in the document (null if the current layer is topmost). (N4)

  • background String specifying the URL of the background image for the layer. (N4)

  • below Reference to the Layer below the current layer according to the z-index order among all layers in the document (null if the current layer is the bottommost). (N4)

  • bgColor String value indicating the named color or hexadecimal triplet of the layer’s background color (e.g., "#FF00FF"). (N4)

  • clip.bottom, clip.height, clip.left, clip.right, clip.top, clip.width Numeric (pixel) values defining the rectangular clipping area of the layer. Any content outside of this rectangle is not displayed. (N4)

  • document Read-only reference to the Document object of the layer. This is a full-featured Document object, complete with the images[] and related collections. Often used to write() content to a layer. (N4)

  • left Pixel value indicating x coordinate of the left edge of the layer. If the layer’s position attribute is "absolute", this placement is relative to the origin of its parent (enclosing) layer. Otherwise, this placement is relative to the content surrounding it. You may use string values with this property to indicate units other than pixels, for example, "25%". (N4)

  • name Read-only value containing the name or id attribute for the layer. (N4)

  • pageX Value represented in pixels indicating the layer’s horizontal position relative to the visible page. (N4)

  • pageY Value represented in pixels indicating the layer’s vertical position relative to the visible page. (N4)

  • parentLayer Reference to Layer in which the current layer is contained (or to the Window object if no such layer exists). (N4)

  • siblingAbove Reference to the Layer above the current layer according to the z-index order among all layers that share the same parent as the current layer, null if it is the topmost. (N4)

  • siblingBelow Reference to the Layer below the current layer according to the z-index order among all layers that share the same parent as the current layer, null if it is the topmost. (N4)

  • src String indicating the URL of the layer’s content. (N4)

  • top Pixel value indicating y coordinate of the top edge of the layer. If the layer’s position attribute is "absolute", this placement is relative to the origin of its parent (enclosing) layer. Otherwise, this placement is relative to the content surrounding it. You may use string values with this property to indicate units other than pixels, for example, "25%". (N4)

  • visibility String indicating whether the layer is visible. A value of "show" makes the layer visible, "hide" makes it invisible, and "inherit" causes it to inherit the visibility property of its parent layer. (N4)

  • window Reference to the window or frame containing the layer. (N4, ReadOnly)

  • x Synonym for left. (N4)

  • y Synonym for top. (N4)

  • zIndex The relative z-index of the layer (with respect to its siblings). (N4)

Methods

  • captureEvents(eventMask) Instructs layer to capture the events given in the bitmask eventMask. (N4)

  • handleEvent(event) Causes the Event instance to be processed by the appropriate handler of the layer. (N4)

  • load() Causes the browser to reload the src of the layer. (N4)

  • moveAbove(whichLayer) Causes the layer to be placed above the Layer referenced by whichLayer. (N4)

  • moveBelow(whichLayer) Causes the layer to be placed below the Layer referenced by whichLayer. (N4)

  • moveBy(x, y) Moves the layer x pixels horizontally and y pixels vertically from its current position. (N4)

  • moveTo(x, y) Moves the layer to the x and y coordinates relative to its parent layer (if absolutely positioned) or relative to its surrounding content (if relatively positioned). (N4)

  • moveToAbsolute(x, y) Moves the layer to the x and y coordinates relative to the visible page. (N4)

  • releaseEvents(eventMask) Instructs layer to stop capturing the events given in the bitmask eventMask. (N4)

  • resizeBy(width, height) Grows or shrinks the layer by the number of pixels given in the arguments. Negative values cause the layer to shrink. (N4)

  • resizeTo(width, height) Resizes the layer to the size in pixels given by the arguments. (N4)

  • routeEvent(event) Passes the Event instance event along normally down the hierarchy. Used to decline to handle an event. (N4)

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:

  • accessKey Single character string indicating the hotkey that gives the element focus. (IE4+, MOZ/N6+, DOM1)

  • align String specifying the alignment of the element, for example, "left". (IE4+, MOZ/N6+, DOM1)

  • dataFld String specifying which field of a data source is bound to the element. (IE4+)

  • dataFormatAs String indicating how the element treats data supplied to it. (IE4+)

  • dataSrc String containing the source of data for data binding. (IE4+)

  • form Reference to the Form in which the element is enclosed. (IE4+, MOZ/N6+, DOM1)

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:

  • type String indicating the type of bullet to be used, for example, "disc", "circle", or "square" for unordered lists. (IE4+, MOZ/N6+, DOM1)

  • value Integer indicating the item number for this item. (IE4+, MOZ/N6+, DOM1)

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:

  • charset String indicating the character set of the linked document. (IE6+, MOZ/N6+, DOM1)

  • disabled Boolean indicating whether the element is disabled (grayed out). (IE4+, MOZ/N6+, DOM1)

  • href String holding the value of the href attribute, the document to load when the link is activated. Defined for Link in traditional models. (IE3+, N2+, MOZ, DOM1)

  • hreflang String indicating the language code of the linked resource. (MOZ/N6+, IE6+, DOM1)

  • media String indicating the media the linked document is intended for. (MOZ/N6+, DOM1)

  • rel String holding the value of the rel property of the element. Used to specify the relationship between documents. (IE4+, MOZ/N6+, DOM1)

  • rev String holding the value of the rev property of the element. Used to specify the relationship between documents, but currently ignored by most browsers. (IE4+, MOZ/N6+, DOM1)

  • target Specifies the target window for a hypertext source link referencing frames. (IE4+, MOZ/N6+, DOM1)

  • type String specifying the advisory content type . (IE4+, MOZ/N6+, DOM1)

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

  • hash String containing the portion of the URL following the hash mark (#), if it exists. (IE3+, N2+, MOZ)

  • host String containing the host name and port of the URL (although some implementations do not include the port). (IE3+, N2+, MOZ)

  • hostname String containing the host name (domain name). (IE3+, N2+, MOZ)

  • href String containing the entire URL. (IE3+, N2+, MOZ)

  • pathname String containing the path (directory) portion of the URL. Always at least "/". (IE3+, N2+, MOZ)

  • port String containing the port number (if one was specified). (IE3+, N2+, MOZ)

  • protocol String containing the protocol and trailing colon (for example, "http:"). (IE3+, N2+, MOZ)

  • search String containing the portion of the URL after the filename (including the ? delimiter if it was specified). (IE3+, N2+, MOZ)

Methods

  • assign(url) Assigns the URL in the string url to the object (just like assigning url to the object). (IE3+, N2+, MOZ)

  • reload(forceGET) Reloads the URL in the current object. The Boolean forceGET parameter (when true) supposedly forces the browser to bypass cache and refetch the document, but experimentation shows that this feature can hardly ever be relied upon. (IE4+, N3+, MOZ)

  • replace(url) Loads the URL given in the string url over the current one found in the object. That is, the new URL replaces the old in the browser’s history (rather than creating a new entry). (IE4+, N3+, MOZ)

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

  • areas[] A read-only collection of areas enclosed by the object. (IE4+, MOZ/N6+, DOM1, ReadOnly)

  • name String holding the name of the image map (for use with usemap). (IE4+, MOZ/N6+, DOM1)

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:

  • bgColor Deprecated property that is used to read or define the background color of the marquee. (IE4+)

  • dataFld String specifying which field of a data source is bound to the element. (IE4+)

  • dataFormatAs String indicating how the element treats data supplied to it. (IE4+)

  • dataSrc String containing the source of data for data binding. (IE4+)

  • direction String value indicating the direction of the marquee. The allowed values are "left", "right", "down", or "up". (IE 4+)

  • loop Numeric value indicating the number of loops the marquee should make. A value of 0 or –1 indicates an endless loop. (IE 4+)

  • scrollAmount A numeric value defining the number of pixels the marquee scrolls per “tick.” (IE 4+)

  • scrollDelay The number of milliseconds between “ticks” that defines the scroll speed. The default value is 85. (IE 4+)

  • trueSpeed A Boolean value that indicates whether the marquee is using the scrollDelay and scrollAmount properties or not. See MSDN for more details. (IE 4+)

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:

  • start() Start the marquee moving. (IE 4+)

  • stop() Stop the marquee animation. (IE 4+)

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

  • E Numeric value containing the base of the natural logarithm (Euler’s constant e). (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1)

  • LN2 Numeric value containing the natural logarithm of 2. (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1)

  • LN10 Numeric value containing the natural logarithm of 10. (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1)

  • LOG2E Numeric value containing the logarithm base 2 of e. (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1)

  • LOG10E Numeric value containing the logarithm base 10 of e. (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1)

  • PI Numeric value of pi (p). (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1)

  • SQRT1_2 Numeric value containing the square root of one-half. (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1)

  • SQRT2 Numeric value containing the square root of two. (E3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1)

Methods

  • abs(arg) Returns the absolute value of arg. (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1)

  • acos(arg) Returns the arc cosine of arg. (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1)

  • asin(arg) Returns the arc sine of arg. (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1)

  • atan(arg) Returns the arc tangent of arg. (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1)

  • atan2(y, x) Returns the angle between the X axis and the point (x, y) in the Cartesian coordinate system, measured counterclockwise (like polar coordinates). Note how y is passed as the first argument rather than the second. (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1)

  • ceil(arg) Returns the ceiling of arg (the smallest integer greater than or equal to arg). (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1)

  • cos(arg) Returns the cosine of arg. (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1)

  • exp(arg) Returns e to arg power. (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1)

  • floor(arg) Returns the floor of arg (the greatest integer less than or equal to arg).

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

  • log(arg) Returns the natural logarithm of arg (log base e of arg). (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1)

  • max(arg1, arg2) Returns the greater of arg1 or arg2. (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1)

  • min(arg1, arg2) Returns the lesser of arg1 or arg2. (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1)

  • pow(arg1, arg2) Returns arg1 to the arg2 power. (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1)

  • random() Returns a random number in the interval [0,1]. (IE3+ (JScript 1.0+), MOZ, N3+ (JavaScript 1.1+), ECMA Edition 1)

  • round(arg) Returns the result of rounding arg to the nearest integer. If the decimal portion of arg is greater than or equal to .5, it is rounded up. Otherwise, arg is rounded down. (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1)

  • sin(arg) Returns the sine of arg. (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1)

  • sqrt(arg) Returns the square root of arg. (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1)

  • tan(arg) Returns the tangent of arg. (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1)

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:

  • compact Boolean indicating whether the list should be compacted by removing extra space between list objects. Generally does not affect appearance in browsers. (IE6+, MOZ/N6+, DOM1)

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:

  • charset Sets the character set used to encode the object. (IE4+, MOZ/N6+)

  • content Specifies the character set used to encode the document. (IE4+, MOZ/N6+, DOM1)

  • httpEquiv String holding the HTTP header name. (IE4+, MOZ/N6+, DOM1)

  • name String holding the name attribute of the element. (IE4+, MOZ/N6+, DOM1)

  • scheme String containing the scheme to use to interpret the value of the header. (IE6+, MOZ/N6+, DOM1)

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

  • description A read-only string containing a human-friendly description of the MIME type. (N3+, MOZ)

  • enabledPlugin A read-only reference to the Plugin object that handles this MIME type. If this MIME type is not associated with a Plugin, this property is null. (N3+, MOZ)

  • suffixes A read-only string containing a comma-separated list of filename extensions (for example, "mid, wav, mp3") that are commonly associated with this MIME type. (N3+, MOZ)

  • type A read-only string containing the actual MIME type of the object in mediatype/subtype format, for example "image/gif". (N3+, MOZ)

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

  • appCodeName A read-only string containing the code name of the browser, for example, "Mozilla". (IE3+, MOZ, NS2+)

  • appMinorVersion A read-only string containing the browser’s minor version value. (IE4+)

  • appName A read-only string containing the name of the browser, for example, "Internet Explorer" or "Netscape". (IE3+, MOZ, NS2+)

  • appVersion A read-only string containing the browser’s version information. (IE3+, MOZ, NS2+)

  • browserLanguage A read-only string containing the language code of the browser or the operating system. IE4 returns the language of the browser while IE5+ returns the language of the operating system. It does not reflect changes made by the user to the browser's language setting. (IE4+)

  • cookieEnabled A read-only Boolean indicating whether persistent cookies are enabled. Does not indicate whether session cookies are enabled. (IE4+, MOZ/N6+)

  • cpuClass A read-only string indicating the CPU of the client computer. Typical values include "x86", "68K", "Alpha", "PPC" (PowerPC), or "Other". (IE4+)

  • language A read-only string indicating the language code of the browser, for example, "en-US". (NS4+, MOZ)

  • mimeTypes[] A read-only array of MimeType objects indicating which MIME types the browser supports. This property is defined in IE5.5, but appears empty. This array can be directly indexed to check for support for a particular MIME type, for example, as “if (navigator.mimeTypes['video/mpeg'] && navigator.mimeTypes['video/mpeg'].pluginEnabled)...“(NS2+, MOZ)

  • onLine A read-only Boolean indicating whether the user is in global offline mode. Global offline mode allows IE to browse local (possibly downloaded) pages while not connected to the network. (IE4+)

  • oscpu A read-only string containing operating system (and sometimes CPU) information, for example, "Win98". (MOZ/N6+)

  • platform A read-only string containing the operating system for which the browser was compiled. Typical values include "Win32", "Win16", "MacPPC", Mac68K", and "SunOS". Under unusual circumstances, could be different from the actual operating system the client is using. (IE4+)

  • plugins[] In Netscape, this read-only array of Plugin objects is installed in the browser and indexed by integer or string referring to the name of a plug-in. Each Plugin is itself an array of mimeType objects. The plugins array provides the refresh(reloadDocs) method that causes newly installed plug-ins to be reflected in the array. When invoked with reloadDocs as true, reloads all the <embed>s in the window (in order to take advantage of a newly installed plug-in). In IE this collection is a synonym for document.embeds[], so it cannot be used for plug-in detection. (IE4+, MOZ, N3+)

  • product A read-only string containing the name of the “product”; in Netscape 6, the name of its engine, "Gecko". (MOZ/N6+, ReadOnly)

  • productSub A read-only string containing the version information about the “product,” apparently the build date string (for example, "20010131"). (MOZ/N6+)

  • securityPolicy The functionality of this property is unclear and not well documented online. It is probably related to Mozilla’s configurable security policies. (MOZ/N6+)

  • systemLanguage A read-only string containing the language edition of the client’s operating system, for example, "en-us". (IE4+)

  • userAgent A read-only string containing the value of the HTTP User-Agent header the browser sends. This property is most commonly used for browser detection and includes much of the information found in other properties of Navigator (for example, language information). (IE3+, MOZ, N2+)

  • userLanguage A read-only string containing the language code of the user’s “natural” language as defined in the operating system specific (Windows) setting. (IE4+)

  • userProfile A read-only reference to the userProfile object for the browser. (IE3+)

  • vendor A read-only string containing browser vendor information, for example, "Netscape6". (MOZ/N6+)

  • vendorSub A read-only string containing vendor version information, for example, "6.01". (MOZ/N6+)

Methods

  • javaEnabled() Returns a Boolean indicating whether Java is enabled. (IE4+, MOZ, N3+)

  • preference(preferenceName [, value]) Invoked by signed scripts with the appropriate privileges to get and set browser preferences. The preferenceName is a string containing the name of the preference to be set or gotten. If value is given, the preference preferenceName is set to value. If value is omitted, the current value of preferenceName is returned. Reading preferences requires the UniversalPreferencesRead privilege. Writing preferences requires UniversalPreferencesWrite. See the Mozilla and Netscape documentation for potential values for preferenceName and value. (N4+, MOZ)

  • savePreferences() Invoked by signed scripts to save the current browser preferences. These preferences are saved to the local file prefs.js (or preferences.js in UNIX). Note that the preferences are saved automatically before quitting the browser. This method requires the UniversalPreferencesWrite privilege. (N4+, MOZ)

  • taintEnabled() Returns a Boolean indicating whether data tainting is enabled. Data tainting is used to prevent scripts from passing private information to remote servers but is no longer a supported technology. (IE5.5+, MOZ, N3+)

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

  • MAX_VALUE Constant holding the largest possible numeric value that can be represented. (IE4+ (JScript 2.0+), MOZ, N3+ (JavaScript 1.1+), ECMA Edition 1)

  • MIN_VALUE Constant holding the smallest possible numeric value that can be represented. (IE4+ (JScript 2.0+), MOZ, N3+ (JavaScript 1.1+), ECMA Edition 1)

  • NaN Constant holding the value NaN. (IE4+ (JScript 2.0+), MOZ, N3+ (JavaScript 1.1+), ECMA Edition 1)

  • NEGATIVE_INFINITY Constant holding the value –Infinity. (IE4+ (JScript 2.0+), MOZ, N3+ (JavaScript 1.1+), ECMA Edition 1)

  • POSITIVE_INFINITY Constant holding the value Infinity. (IE4+ (JScript 2.0+), MOZ, N3+ (JavaScript 1.1+), ECMA Edition 1)

  • prototype Reference to the object’s prototype. (IE4+ (JScript 2.0+), MOZ, N3+ (JavaScript 1.1+), ECMA Edition 1)

Methods

  • toExponential([fracDigits]) Returns a string holding the number in exponential notation. If specified, only the number of digits given in facDigits will be used after the decimal point. (IE5.5+ (JScript 5.5+), MOZ/N6+ (JavaScript 1.5+), ECMA Edition 3)

  • toFixed([fracDigits]) Returns a string holding the number in fixed-point notation. If specified, only the number of digits given in fracDigits will be used after the decimal point. (IE5.5+ (JScript 5.5+), MOZ/N6+ (JavaScript 1.5+), ECMA Edition 3)

  • toPrecision([numDigits]) Returns a string holding the number in fixed-point or exponential notation rounded to the number of digits after the decimal point given in numDigits. (IE5.5+ (JScript 5.5+), MOZ/N6+ (JavaScript 1.5+), ECMA Edition 3)

  • toLocaleString() Returns a string holding the value of the number formatted according to local (operating system) conventions. (IE5.5+ (JScript 5.5+), MOZ/N6+ (JavaScript 1.5+), ECMA Edition 3)

  • toString([radix]) Returns the number as a string in base radix (defaults to 10). (IE4+ (JScript 2.0+), MOZ, N3+ (JavaScript 1.1+), ECMA Edition 1)

  • valueOf() Returns the primitive number value of the object. (IE4+ (JScript 2.0+), MOZ, N3+ (JavaScript 1.1+), ECMA Edition 1)

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

  • prototype The prototype for the object. This object defines the properties and methods common to all objects of this type. (IE4+ (JScript 3.0+), MOZ, N3+ (JavaScript 1.1+), ECMA Edition 1)

Methods

  • hasOwnProperty(property) Returns a Boolean indicating whether the object has an instance property by the name given in the string property. (IE5.5+, MOZ/N6+, ECMA Edition 3)

  • isPrototypeOf(obj) Returns a Boolean indicating if the object referenced by obj is in the object’s prototype chain. (IE5.5+, MOZ/N6+, ECMA Edition 3)

  • propertyIsEnumerable(property) Returns a Boolean indicating if the property with the name given in the string property will be enumerated in a for/in loop. (IE5.5+, MOZ/N6+, ECMA Edition 3)

  • toSource() Returns a string containing a JavaScript literal that describes the object. (MOZ, N4.06+ (JavaScript 1.3+))

  • toString() Returns the object a string, by default "[object Object]". Very often overridden to provide specific functionality. (IE4+ (JScript 3.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1)

  • unwatch(property) Disables watching of the object’s property given by the string property. (N4 (JavaScript 1.2))

  • valueOf() Returns the primitive value associated with the object, by default the string "[object Object]". Often overridden to provide specific functionality. (IE4+ (JScript 3.0+), N3+ (JavaScript 1.1+), ECMA Edition 1)

  • watch(property, handler) Sets a watch on the object’s property given in string property. Whenever the value of the property changes, the function handler is invoked with three arguments: the name of the property, the old value, and the new value it is being set to. The handler can override the setting of the new value by returning a value, which is set in its place. (N4 (JavaScript 1.2))

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).

  • align String specifying the alignment of the element, for example, "left". (IE4+, MOZ/N6+, DOM1)

  • alt Sets a text alternative to the object. (IE6+)

  • altHtml Sets the optional alternative HTML to use if the object fails to load. (IE4+)

  • archive Sets a character string that can be used to implement your own archive functionality for the object. (IE6+, MOZ/N6+, DOM1)

  • baseURI String containing the URL relative to which relative URLs for the object will be resolved. (MOZ/N6+)

  • baseHref String relative to which relative URLs for the object will be resolved. (IE3+)

  • border Sets the width of the border to draw around the object. (IE6+, MOZ/N6+, DOM1)

  • classid String containing the class identifier of the object. Used with Java applets or ActiveX controls. (IE3+)

  • code Sets the URL of the file containing the compiled Java class. Using classid and codebase is far more common. (IE4+, MOZ/N6+, DOM1)

  • codeBase Sets the URL of the embedded object. (IE3+, MOZ/N6+, DOM1)

  • codeType Sets the MIME type for the object. (IE3+, MOZ/N6+, DOM1)

  • data Sets the URL that references data intended for the object. (IE3+, MOZ/N6+, DOM1)

  • dataFld String specifying which field of a data source is bound to the element. (IE4+)

  • dataFormatAs String indicating how the element treats data supplied to it. (IE4+)

  • dataSrc String containing the source of data for data binding. (IE4+)

  • declare Sets a character string that can be used to implement your own declare functionality for the object. There is none by default. (IE6+, MOZ/N6+, DOM1)

  • form Reference to the form that the object is embedded in or null otherwise. (IE4+, MOZ/N6+, DOM1)

  • height Specifies the height in pixels of the object. (IE3+, MOZ/N6+, DOM1)

  • hspace Sets the horizontal margin for the object. (IE3+, MOZ/N6+, DOM1)

  • name String holding the name attribute of the element. (IE4+, MOZ/N6+, DOM1)

  • object Reference to the object contained by the element. This property is used when the document and the object have conflicting namespaces. (IE4+)

  • standby Sets a character string that can be used to implement your own standby functionality for the object. There is no functionality by default. (IE6+, MOZ/N6+, DOM1)

  • tabIndex Numeric value indicating the tab order for the object. (IE4+, MOZ/N6+, DOM1)

  • type Specifies the MIME type for the data the object uses. (MOZ/N6+, IE6+, DOM1)

  • useMap Sets the URL, often with a bookmark extension (#name), to use as a client-side image map. (IE6+, MOZ/N6+, DOM1)

  • vspace Sets the vertical margin for the object. (IE3+, MOZ/N6+, DOM1)

  • width Specifies the width of the object in pixels. (IE3+, MOZ/N6+, DOM1)

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:

  • compact Boolean indicating whether the list should be compacted by removing extra space between list objects. (IE4+, MOZ/N6+, DOM1)

  • start Sets the starting number or letter, for example, "3" or "C". Often used in conjunction with the type property. (IE4+, MOZ/N6+, DOM1)

  • type Sets the style of list numbering: "1" for numbers, "a" for lowercase letters, "A" for uppercase letters, or "i" or "I" for uppercase or lowercase roman numerals. (IE3+, MOZ/N6+, DOM1)

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:

  • disabled Boolean indicating whether the element is disabled (grayed out). (IE6+, MOZ/N6+, DOM1)

  • label String that sets the label for the option group. (IE6+, MOZ/N6+, DOM1)

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 options 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:

  • dataFld String specifying which field of a data source is bound to the element. (IE4+)

  • dataFormatAs String indicating how the element treats data supplied to it. (IE4+)

  • dataSrc String containing the source of data for data binding. (IE4+)

  • defaultSelected A read-only Boolean indicating if this option is the default. (IE3+, N2+, MOZ, DOM1)

  • disabled Boolean indicating whether the element is disabled (grayed out). (IE5.5+, MOZ/N6+, DOM1)

  • form Read-only reference to the Form in which the element is contained. (IE3+, N2+, MOZ, DOM1)

  • index The read-only index of the option in the enclosing select. (IE3+, N2+, MOZ, DOM1)

  • label The alternate text for the option as specified in the label attribute. (IE6+, MOZ/N6+, DOM1)

  • selected Boolean indicating if the element is selected. (IE3+, N2+, MOZ, DOM1)

  • text String containing the text enclosed by the element. (IE3+, N2+, MOZ, DOM1)

  • value String containing the value of the element's value attribute. (IE3+, N2+, MOZ, DOM1)

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:

  • align String specifying the alignment of the element, for example, "left". (IE4+, MOZ/N6+, DOM1)

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

  • pseudoClass Read-only string value that identifies the pseudo class of the page or pages an @page rule applies to. Allowed values are :first, :left, and :right. There is no default value for this property.

  • selector Read-only string value that identifies which page or pages an @page rule applies to.

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:

  • name String holding the name of the parameter. (IE6+, MOZ/N6+, DOM1)

  • type String indicating the type of the value when valueType is "ref". The value should be read-only after the related <object> has loaded. (IE6+, MOZ/N6+, DOM1)

  • value String containing the value of the parameter. The value should be read-only after the related <object> has loaded. (IE6+, MOZ/N6+, DOM1)

  • valueType String giving more information about how to interpret value, usually "data", "ref", or "object". The value should be read-only after the related <object> has loaded. (IE6+, MOZ/N6+, DOM1)

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

  • description A read-only string containing a human-friendly description of the plug-in. (MOZ, N3+)

  • filename A read-only string containing the filename of the plug-in on the local disk. (MOZ, N3+)

  • length A read-only value indicating the number of mimeType objects contained in the object (the length of its array content). Equivalently, the number of MIME types the plug-in is currently handling. (MOZ, N3+)

  • name A read-only string specifying the name of the plug-in, for example, "Shockwave Flash". Carefully consult plug-in vendor documentation to find the exact name of the plug-in(s) in which you are interested. (MOZ, N3+)

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

  • document Reference to the window’s Document (initially empty). (IE5.5+)

  • isOpen Boolean indicating if the window is open. (IE5.5+)

Methods

  • hide() Hides the window. (IE5.5+)

  • show(x, y, width, height [, relativeTo]) Renders the window visible at screen coordinates (x,y) relative to the desktop. The size of the window is given in the pixel arguments width and height. The relativeTo parameter is a reference to an object relative to which the x and y coordinates will be interpreted. (IE5.5+)

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:

  • width Specifies the width of the object in pixels. (IE6+, MOZ/N6+, DOM1)

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:

  • cite String containing the URL that serves as a reference for the quote. (IE6+, MOZ/N6+, DOM1)

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:

  • accessKey Single character string indicating the hotkey that gives the element focus. (IE4+, MOZ/N6+, DOM1)

  • align String specifying the alignment of the element, for example, "left". (IE4+, MOZ/N6+, DOM1)

  • alt String containing alternative text for the button (for browsers incapable of rendering buttons). (MOZ/N6+, DOM1)

  • checked Boolean indicating whether the button is currently checked. (IE3+, MOZ, N2+, DOM1)

  • dataFld String specifying which field of a data source is bound to the element. (IE4+)

  • dataFormatAs String indicating how the element treats data supplied to it. (IE4+)

  • dataSrc String containing the source of data for data binding. (IE4+)

  • defaultChecked Boolean indicating if the radio is checked by default (i.e., whether its checked attribute was specified). (IE3+, MOZ, N2+, DOM1)

  • defaultValue String containing the initial value of the radio’s value attribute. (IE3+, MOZ/N6+, DOM1)

  • disabled Boolean indicating whether the element is disabled (grayed out). (IE4+, MOZ/N6+, DOM1)

  • form Read-only reference to the Form in which the button is contained. (IE3+, MOZ, N2+, DOM1)

  • name Read-only string holding the name attribute of the element. (IE3+, MOZ, N2+, DOM1)

  • status Boolean indicating if the radio is selected. (IE4+)

  • tabIndex Numeric value indicating the tab order for the object. (IE4+, MOZ/N6+, DOM1)

  • type Read-only string containing the type of the input, in this case "radio". (IE4+, MOZ, N3+, DOM1)

  • value The value attribute of the button. (IE3+, MOZ, N2+, DOM1)

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:

  • blur() Removes focus from the element. (IE3+, MOZ, N2+, DOM1)

  • click() Simulates a mouse click at the object. (IE3+, MOZ, N2+, DOM1)

  • focus() Gives focus to the element. (IE3+, MOZ, N2+, DOM1)

  • handleEvent(event) Passes the Event event to be handled by the object. (N4 only)

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

  • $1, $2, ... $9 The $n property contains the string corresponding to the nth parenthesized subexpression of the most recently executed match. The properties are read-only. (IE4+ (JScript 3.0+), MOZ, N4+ (JavaScript 1.2+))

  • global A read-only Boolean indicating whether the global flag ("g") was used to create the regular expression. (IE5.5+ (JScript 5.5+), MOZ, N4+ (JavaScript 1.2+), ECMA Edition 3)

  • ignoreCase A read-only Boolean indicating whether the case-insensitive flag ("i") was used to create the regular expression. (IE5.5+ (JScript 5.5+), MOZ, N4+ (JavaScript 1.2+), ECMA Edition 3)

  • index A read-only integer value indicating the character position where the first successful match begins (during the most recently executed match). (IE4+ (JScript 3.0+))

  • input Holds the string upon which the most recent regular expression match was conducted. This property is not automatically filled in N6. (IE4+ (JScript 3.0+), MOZ, N4+ (JavaScript 1.2+))

  • lastIndex Integer specifying the character index of the string at which the next match will begin. Used during global matching. (IE4+ (JScript 3.0+), MOZ, N4+ (JavaScript 1.2+), ECMA Edition 3)

  • lastMatch A read-only string containing the last matched characters of the most recent match. (IE5.5+ (JScript 5.5+), MOZ, N4+ (JavaScript 1.2+))

  • lastParen A read-only string containing the last matched parenthesized subexpression (of the most recent match). (IE5.5+ (JScript 5.5+), MOZ, N4+ (JavaScript 1.2))

  • leftContext A read-only substring up to but not including the beginning of the most recently matched text (of the most recently executed match). (IE5.5+ (JScript 5.5+), MOZ, N4+ (JavaScript 1.2))

  • multiline A read-only Boolean indicating whether the multiline flag ("m") was used to create the regular expression. (IE5.5+ (JScript 5.5+), MOZ, N4+ (JavaScript 1.2+), ECMA Edition 3)

  • prototype Reference to the object’s prototype. (IE4+ (JScript 3.0+), MOZ, N4+ (JavaScript 1.2+), ECMA Edition 3)

  • rightContext A read-only substring following (but not including) the most recently matched text. (IE5.5+ (JScript 5.5+), MOZ, N4+ (JavaScript 1.2), ECMA Edition 3)

  • source A read-only string containing the text that makes up the pattern (excluding any slashes used to define it and the flags). (IE4+ (JScript 3.0+), MOZ, N4+ (JavaScript 1.2), ECMA Edition 3)

Methods

  • compile(expr [, flags]) Compiles the regular expression expr with flags flags in the object. Used to replace an expression with a new one. (IE4+ (JScript 3.0+), MOZ, N4+ (JavaScript 1.2), ECMA Edition 3)

  • exec(str) Executes a match against the string str and returns an array containing the results. If no match was made, null is returned. If str is omitted, the contents of RegExp.input is used as str. The resulting array has the entire match in element zero, and any matched subexpressions at subsequent indices. It also has instance properties input (which holds the string on which the match was executed), index (which holds the index of the beginning of the match in the input string), and in IE lastIndex (which holds the index of the first character following the match). (IE4+ (JScript 3.0+), MOZ, N4+ (JavaScript 1.2), ECMA Edition 3)

  • test(str) Returns a Boolean indicating whether the regular expression matches a part of the string str. (IE4+ (JScript 3.0+), MOZ, N4+ (JavaScript 1.2), ECMA Edition 3)

  • toString() Returns the string corresponding to the regular expression, including enclosing slashes and any flags that were used to define it. (IE4+ (JScript 3.0+), MOZ, N4+ (JavaScript 1.2), ECMA Edition 3)

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 Forms 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:

  • accessKey Single character string indicating the hotkey that gives the element focus. (IE4+, MOZ/N6+, DOM1)

  • align String specifying the alignment of the element, for example, "left". (IE4+, MOZ/N6+, DOM1)

  • alt String containing alternative text for the button (for browsers incapable of rendering buttons). (MOZ/N6+, DOM1)

  • dataFld String specifying which field of a data source is bound to the element. (IE4+)

  • dataFormatAs String indicating how the element treats data supplied to it. (IE4+)

  • dataSrc String containing the source of data for data binding. (IE4+)

  • defaultValue String containing the initial value of the button’s value attribute. (IE3+, MOZ/N6+, DOM1)

  • disabled Boolean indicating whether the element is disabled (grayed out). (IE4+, MOZ/N6+, DOM1)

  • form Reference to the Form containing the button. (IE3+, MOZ, N2+, DOM1, ReadOnly)

  • name String holding the name attribute of the element. (IE3+, MOZ, N2+, DOM1)

  • tabIndex Numeric value indicating the tab order for the object. (IE4+, MOZ/N6+, DOM1)

  • type Read-only string containing the type of the input, in this case "reset". (IE4+, MOZ, N3+, DOM1)

  • value The value attribute of the button. (IE3+, MOZ, N2+, DOM1)

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:

  • blur() Removes focus from the element. (IE3+, MOZ, N2+, DOM1)

  • click() Simulates a mouse click at the object. (IE3+, MOZ, N2+, DOM1)

  • createTextRange() Creates a TextRange object for examination or manipulation of the button’s text. A better cross-browser solution is to use standard String methods on the field’s value. (IE4+)

  • focus() Gives focus to the element. (IE3+, MOZ, N3+, DOM1)

  • handleEvent(event) Passes the Event event to be handled by the object. (N4 only)

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

  • cssText String containing the text of the rule. (MOZ/N6+, IE5 MacOS only, DOM2)

  • parentRule Reference to the rule this rule is contained within, if any. (MOZ/N6+, DOM2)

  • parentStyleSheet A read-only reference to the styleSheet object in which the rule is defined. (MOZ/N6+, IE5 MacOS only, DOM2)

  • readOnly A read-only Boolean indicating if the style sheet in which the rule is defined was loaded from an external file. (IE4+)

  • selectorText String containing the selector portion of the rule. (IE4+, MOZ/N6+, DOM2, ReadOnly)

  • style Reference to the Style object that defines the style properties of the selector. Changing this object is reflected in any elements bound by the rule. (IE4+, MOZ/N6+h, DOM2)

  • type Integer indicating the type of rule: 0 (unknown), 1 (normal style rule), 2 (@charset rule), 3 (@import rule), 4 (@media rule), 5 (@font-face rule), 6 (@page rule). (MOZ/N6+, DOM2)

Methods

None.

Notes

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

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

  • availHeight Read-only value specifying the height of the user’s screen minus any operating system chrome (such as the Windows taskbar). (IE4+, MOZ, N4+)

  • availLeft Read-only value indicating the x coordinate of the first pixel on the left side of the screen that is not occupied by an operating system object. (N4+, MOZ)

  • availTop Read-only value indicating the y coordinate of the first pixel at the top of the screen that is not occupied by an operating system object. (N4+, MOZ)

  • availWidth Read-only value specifying the width of the user’s screen minus any operating system chrome in pixels. (IE4+, MOZ, N4+)

  • bufferDepth Specifies the number of bits per pixel to use for colors in the offscreen bitmap buffer. Valid values are zero (the default), –1 (use the colorDepth value), or a power of two up to 32. (IE4+)

  • colorDepth Read-only value holding the number of bits per pixel used for colors. (IE4+, MOZ, N4+)

  • deviceXDPI Integer indicating the number of dots per inch on the screen in the horizontal direction. (IE6+)

  • deviceYDPI Integer indicating the number of dots per inch on the screen in the vertical direction. (IE6+)

  • fontSmoothingEnabled Read-only Boolean indicating whether the user has font smoothing enabled in Windows. (IE4+)

  • height The vertical resolution of the screen in pixels. (IE4+, MOZ, N4+, ReadOnly)

  • left x coordinate of the left side of the content area in the browser window. (MOZ/N6+)

  • logicalXDPI Integer indicating the usual number of dots per inch on the screen in the horizontal direction. (IE6+)

  • logicalYDPI Integer indicating the usual number of dots per inch on the screen in the vertical direction. (IE6+)

  • pixelDepth Read-only value containing the number of bits per pixel used for colors. (MOZ, N4+)

  • top y coordinate of the top of the content area in the browser window. (MOZ/N6+)

  • updateInterval Integer indicating how often the screen should be repainted in milliseconds. Defaults to zero but can be set to larger values if there is a lot of repainting going on that should be buffered. (IE4+)

  • width Read-only value holding the horizontal resolution of the screen in pixels. (IE4+, MOZ, N4+)

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:

  • charset String specifying the character set used to encode the script. (IE6+, MOZ/N6+, DOM1)

  • defer Boolean indicating whether execution of the script is deferred. Used to indicate to the browser that the script is not going to generate any content for the document and so its parsing and execution may be deferred to speed up document rendering. (IE4+, MOZ/N6+, DOM1)

  • event In IE, this string specifies the handler the script is for (for example, "onclick()") and is used in conjunction with htmlFor. Using this property for that purpose is not recommended as it is nonstandard, although the W3C has reserved this property for future use (probably to implement similar functionality). In Netscape, this property is useless. (IE4+, MOZ/N6+, DOM1)

  • htmlFor In IE, this string specifies the object that the script is for, and is used in conjunction with the event property/attribute. This property corresponds to the for attribute. Using this property to bind events is not recommended at the current time because it is nonstandard, although the W3C has reserved this property for future use (probably to implement similar functionality). This property is useless in Netscape 6+. (IE4+, MOZ/N6+, DOM1)

  • src String holding the URL of the external script. (IE4+, MOZ/N6+, DOM1)

  • text String holding the contents of the script. (IE4+, MOZ/N6+, DOM1)

  • type String holding the value of the type attribute, the MIME type of the script. (IE4+, MOZ/N6+, DOM1)

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:

  • dataFld String specifying which field of a data source is bound to the element. (IE4+)

  • dataFormatAs String indicating how the element treats data supplied to it. (IE4+)

  • dataSrc String containing the source of data for data binding. (IE4+)

  • disabled Boolean indicating whether the element is disabled (grayed out). (IE4+, MOZ/N6+, DOM1)

  • form Read-only reference to the Form in which the element is contained. (IE3+, MOZ, N2+, DOM1)

  • length Indicates the number of options in the selection list. (IE3+, MOZ, N2+, DOM1)

  • multiple Boolean indicating if multiple options may be selected. (IE4+, MOZ/N6+, DOM1)

  • name String holding the name attribute of the element. (IE3+, MOZ, N2+, DOM1)

  • options[] Collection of options contained by this element. IE supplies methods with this array, so see options.add() and options.remove() later in this section. (IE3+, MOZ, N2+, DOM1)

  • selectedIndex Integer indicating the index in the options[] collection of the option that is currently selected or –1 if none is. If multiple options are selected, the index of the first one is returned. (IE3+, MOZ, N2+, DOM1)

  • size Indicates the size attribute of the select, in other words, the number of options that are visible at one time. (IE4+, MOZ/N6+, DOM1)

  • tabIndex Numeric value indicating the tab order for the object. (IE4+, MOZ/N6+, DOM1)

  • type A read-only string containing the type of the select, either "select-one" or "select-multiple". (IE4+, MOZ, N3+, DOM1)

  • value String containing the value of the currently selected option. (IE4+, MOZ/N6+, DOM1)

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:

  • add(element, before) Adds the option referenced by element to the list of options before the option referenced by before. If before is null, it is added at the end of the list. Under IE, before is an optional index at which to insert the new element (shifting the rest of the options up one index). (IE5.5+, MOZ, DOM1)

  • blur() Removes focus from the element. (IE3+, MOZ, N2+, DOM1)

  • focus() Gives focus to the element. (IE4+, MOZ, N2+, DOM1)

  • options.add(element [, index]) Adds the option referenced by element to the options[] collection at index index (if specified), shifting the other options up one index. If index is not specified, the new option is added to the end of the list. (IE4+)

  • options.remove(index) Removes the option at index index and shifts the remaining options down one index. (IE4+)

  • remove(index) Removes the option at index index from the list of options. (IE5.5+, MOZ/N6+, DOM1)

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

  • type A read-only string indicating the type of selection. Either "none" (if there is no selected content), "text" (if the selected content is text/element content), or "control" (if the selected content is a control select—one in which the selected object can be resized). (IE4+)

  • TextRange[] A collection of TextRange objects for the selection. (IE4+)

  • typeDetail The read-only name of the selection, most often not defined. (IE5.5+)

Methods

  • clear() Clears the contents of the selection. (IE4+)

  • createRange() Creates a TextRange out of the selection and returns a reference to the new object. Or if the selection is a control selection, creates a controlRange collection. (IE4+)

  • createRangeCollection() Same as createRange() in IE, although other JScript implementations may return a collection of TextRange objects created from the selection. (IE5.5+)

  • empty() Cancels the current selection. (IE4+)

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 Element object found at the beginning of this section:

  • dataFld String specifying which field of a data source is bound to the element. (IE4+)

  • dataFormatAs String indicating how the element treats data supplied to it. (IE4+)

  • dataSrc String containing the source of data for data binding. (IE4+)

Methods

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

  • doScroll([action]) Simulates activity on the span’s scroll bar if it has one. If action is specified it must be one of several predetermined strings, such as "left" or "right", which give fine-grained control over scroll bar actions. See MSDN for complete details. (IE5+)

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

  • length Integer indicating the number of characters in the string. (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1)

  • prototype Reference to the object’s prototype. (IE4+ (JScript 2.0+), MOZ, N3+ (JavaScript 1.1+), ECMA Edition 1)

Methods

  • anchor(name) Returns the string marked up as an HTML anchor (<a name="name">

  • string value</a>). (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1).

  • big() Returns the string marked up as big HTML text (<big>string value</big>). (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+))

  • blink() Returns the string marked up as blinking HTML text (<blink>string value</blink>). (IE3+ (JScript 1.0+), N2+ (JavaScript 1.0+), MOZ)

  • bold() Returns the string marked up as bold HTML text (<bold>string value</bold>). (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+))

  • charAt(position) Returns a string containing the character at index position in the string. The empty string is returned if position is out of range. (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1)

  • charCodeAt(position) Returns an unsigned integer representing the Unicode value of the character at index position. If position is out of range, NaN is returned. (IE5.5+ (JScript 5.5+), MOZ, N4+ (JavaScript 1.2+), ECMA Edition 1)

  • concat(string2 [, string3 [, ... ]]) Returns the string obtained by concatenating the current string value with string2, string3, .... (IE4+ (JScript 3.0+), MOZ, N4+ (JavaScript 1.2+), ECMA Edition 1)

  • fixed() Returns the string marked up as fixed-width HTML text (<tt>string value</tt>). (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+))

  • fontcolor(theColor) Returns the string marked up as colored HTML according to the string color (<font color="theColor">string value</font>). (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+))

  • fontsize(theSize) Returns the string marked up according to the HTML font size given in theSize (<font size="theSize">string value</font>). HTML font sizes are 1 through 7, or relative +/– 1–6. (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+))

  • fromCharCode(char0 [, char1 [, ...]]) Creates a string from the given characters. The arguments char0, char1, ... are Unicode numbers corresponding to the desired characters. (IE4+ (JScript 3.0+), MOZ, N4+ (JavaScript 1.2+), ECMA Edition 1, Static)

  • indexOf(searchString [, startIndex]) Returns the index of the first occurrence of searchString in the string. If startIndex is specified, then the first occurrence after index startIndex is returned. If searchString is not found, –1 is returned. (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1)

  • italics() Returns the string marked up as italicized HTML text (<i>string value</i>). (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+))

  • lastIndexOf(searchString [, startIndex]) Returns the index of the last occurrence of searchString in the string. If startIndex is specified, the index of the last occurrence starting at index startIndex or before is returned. If searchString is not found, –1 is returned. (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1)

  • link(theHref) Returns the string marked up as an HTML link to the string theHref (<a href="theHref">string value</a>). (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+))

  • match(regexp) Executes a regular expression match with the regular expression regexp and returns an array of results. If no match is found, null is returned. Otherwise, the returned array is exactly like that returned by RegExp.exec(). (IE4+ (JScript 3.0+), MOZ, N4+ (JavaScript 1.2+), ECMA Edition 3)

  • replace(regexp, replacement) Returns the string obtained by executing a match with the regular expression regexp on the string and then replacing each piece of matching text with the string replacement. In IE5.5 and N4.06+ replacement can be a function (see full description at MSDN). (IE3+ (JScript 1.0+), MOZ, N4+ (JavaScript 1.2+), ECMA Edition 3)

  • search(regexp) Executes a regular expression match with regular expression regexp and returns the index of the beginning of the matching text in the string. If no match is found, –1 is returned. (IE4+ (JScript 3.0+), MOZ, N4+ (JavaScript 1.2+), ECMA Edition 3)

  • slice(start [, end]) Returns a new string containing the substring from index start up to but not including index end. If end is omitted, the substring returned runs to the end of the string. If start or end is negative, it is treated as an offset from the end of the string. (IE4+ (JScript 3.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 3)

  • small() Returns the string marked up as small HTML text (<small>string value</small>). (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+))

  • split([separator [, limit]]) Returns the array of strings obtained by splitting the string at each occurrence of separator (which may be a string or regular expression). The separator is not included in the array returned. If no separator is given, the string is split into an array of strings holding its individual characters. If the integer limit is given, only the first limit parts are placed in the array. (IE4+ (JScript 3.0+), MOZ, N3+ (JavaScript 1.1+), ECMA Edition 1)

  • strike() Returns the string marked up as struck-through HTML text (<strike>string value</strike>). (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+))

  • sub() Returns the string marked up as subscript HTML text (<sub>string value</sub>). (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+))

  • substr(start [, length]) Returns a new string containing a substring of length length beginning at index start. If length is not given, the substring returned runs to the end of the string. (IE4+ (JScript 3.0+), MOZ, N2+ (JavaScript 1.0+))

  • substring(start [, end]) Returns a new string containing the substring running from index start up to but not including index end. If end is not given, the substring runs to the end of the string. If start is greater than end, the values are swapped. (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1)

  • sup() Returns the string marked up as superscript HTML text (<sup>string value</sup>). (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+))

  • toLowerCase() Returns the string converted to all lowercase. (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1)

  • toUpperCase() Returns the string converted to all uppercase. (IE3+ (JScript 1.0+), MOZ, N2+ (JavaScript 1.0+), ECMA Edition 1)

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

  • cssText String containing the CSS definition of this style. (IE4+, MOZ/N6+, DOM2)

  • parentRule String containing a reference to the parent CSS rule, if one exists (MOZ/N6+, DOM2)

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

  • borderWidths(top, right, bottom, left) Sets the borders for the element according to its pixel value string arguments. (N4 only)

  • margins(top, right, bottom, left) Sets the margins for the element according to its pixel value string arguments. (N4 only)

  • paddings(top, right, bottom, left) Sets the padding for the element according to its pixel value string arguments. (N4 only)

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:

  • disabled Boolean indicating whether the element is disabled (grayed out). (IE4+, MOZ/N6+, DOM1)

  • media String containing the value of the element’s media attribute, if one was defined. (IE4+, MOZ/N6+, DOM1 HTML)

  • sheet A read-only reference to the styleSheet object corresponding to the element. (MOZ/N6+)

  • styleSheet Reference to the styleSheet object corresponding to the element. (IE4+, ReadOnly)

  • type String containing the value of the type attribute for the style sheet. Usually "text/css". (IE4+, MOZ/N6+, DOM1)

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 rules 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

  • cssRules[] A read-only array of rule objects defined by the style sheet. (IE5+ MacOS only, MOZ/N6+, DOM2)

  • cssText String containing the rules defined by the style sheet. Manipulating rule objects is preferable to modifying this property. (IE5+)

  • disabled Boolean indicating whether the style sheet is disabled. (IE4+, MOZ/N6+, DOM2)

  • href String containing the value of the href attribute, if the style sheet was included using a <link> tag. (IE4+, MOZ/N6+, DOM2)

  • id String holding the unique alphanumeric identifier for the element. (IE4+, DOM2)

  • imports[] A read-only array of styleSheet objects corresponding to style sheets included in the current style sheet using @import. (IE4+)

  • media String holding the media attribute of the style sheet. (IE4+, MOZ/N6+, DOM2)

  • ownerNode A read-only reference to the top-level node in the document in which the style sheet is defined. (MOZ/N6+, DOM2)

  • ownerRule A read-only reference to the rule object that included the style sheet, if it was included with @import. Note that Mozilla/Netscape 6+ does not reflect imported style sheets as styleSheet objects. (MOZ/N6+, DOM2)

  • owningElement A read-only reference to the element in which the style sheet was defined—for example, a <style> or <link> object. (IE4+)

  • pages[] Array of rule objects corresponding to @page rules. See page object. (IE5.5+)

  • parentStyleSheet If the style sheet was imported using @import, this property is a reference to the styleSheet object for the style element in which it was imported; otherwise, the value is null. The property is read-only. (IE4+, MOZ/N6+, DOM2)

  • readOnly A read-only Boolean indicating if the style sheet originated from an external file—for example, if it was included with a <link> or @import. Does not really mean that the style sheet is read-only. (IE4+)

  • rules[ ] A read-only collection of rule objects defined by the style sheet. (IE4+)

  • title String containing title attribute of the element in which the style sheet was defined. (IE4+, MOZ/N6+, DOM2)

  • type String containing the value of the type attribute of the element in which the style sheet was defined. Usually "text/css". (IE4+, MOZ/N6+, DOM2)

Methods

  • addImport(url [, index]) Adds an @import rule to the style sheet and imports the style sheet referenced by the string url. If index is specified, the new rule is inserted at that index in the rules[] collection. Otherwise, it is appended to the end. Returns the index at which the rule was added. (IE4+)

  • addPageRule(selector, rule, index) Adds a new @page rule to the style sheet with the given selector and rule (value). The index is the position in the pages[] collection at which the rule should be placed (–1 means to add it at the end). (IE5.5+)

  • addRule(selector, value [, index]) Inserts a new rule with selector given in string selector and value given in string value. The value should not include the curly braces you would normally use, and it is a semicolon-separated list of values. If index is specified, the new rule is inserted at that position in the rules[] collection; otherwise, it is appended to the end—for example, "addRule('.important','color:red;font-weight:bold')". (IE4+)

  • deleteRule(index) Removes the rule at index index in the cssRules[] collection. (MOZ/N6+, DOM2)

  • insertRule(rule, index) Adds the rule given in string rule to the cssRules[] collection at index index. To add the rule to the end, use the length property of cssRules for index. The rule string should be exactly as you would normally specify a CSS rule, for example, "insertRule('.important { color:red; font-weight: bold }', 0)". (MOZ/N6+, DOM2)

  • removeRule(index) Removes the rule at index index in the rules[] collection. (IE4+)

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 Forms 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:

  • accessKey Single character string indicating the hotkey that gives the element focus. (IE4+, MOZ/N6+, DOM1)

  • align String specifying the alignment of the element, for example, "left". (IE3+, MOZ, N2+, DOM1)

  • alt String containing alternative text for the button (for browsers incapable of rendering buttons). (MOZ/N6+, DOM1)

  • dataFld String specifying which field of a data source is bound to the element. (IE4+)

  • dataFormatAs String indicating how the element treats data supplied to it. (IE4+)

  • dataSrc String containing the source of data for data binding. (IE4+)

  • defaultValue String containing the initial value of the button’s value attribute. (IE3+, MOZ/N6+, DOM1)

  • disabled Boolean indicating whether the element is disabled (grayed out). (IE4+, MOZ/N6+, DOM1)

  • form Reference to the Form containing the button. (IE3+, MOZ, N2+, DOM1, ReadOnly)

  • name String holding the name attribute of the element. (IE3+, MOZ, N2+, DOM1)

  • tabIndex Numeric value indicating the tab order for the object. (IE4+, MOZ/N6+, DOM1)

  • type String containing the type of the input, in this case "submit". (IE4+, MOZ, N3+, DOM1, ReadOnly)

  • value The value attribute of the button. (IE3+, MOZ, N2+, DOM1)

Methods

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

  • blur() Removes focus from the element. (IE3+, MOZ, N2+, DOM1)

  • click() Simulates a mouse click at the object. (IE3+, MOZ, N2+, DOM1)

  • createTextRange() Creates a TextRange object for examination or manipulation of the button’s text. A better cross-browser solution is to use standard String methods on the field’s value. (IE4+)

  • focus() Gives focus to the element. (IE3+, MOZ, N2+, DOM1)

  • handleEvent(event) Passes the Event event to be handled by the object. (N4 only)

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:

  • background String containing the URL of the background image for the table. (IE4+)

  • bgColor String containing the background color for the table. (IE4+, MOZ/N6+, DOM1)

  • border String specifying the width of the border to draw around the table. (IE4+, MOZ/N6+, DOM1)

  • borderColor String specifying the color of the border. (IE4+)

  • borderColorDark String specifying the dark border color for 3D borders. (IE4+)

  • borderColorLight String specifying the light border color for 3D borders. (IE4+)

  • caption Reference to the caption object for this table. (MOZ/N6+, DOM1)

  • cellPadding String specifying the space between the cell wall and the content. (IE4+, MOZ/N6+, DOM1)

  • cellSpacing String specifying the space between adjacent cells. (IE4+, MOZ/N6+, DOM1)

  • cells[] Collection of all the cells in the table. (IE5+)

  • cols Integer specifying the number of columns in the table. (IE4+)

  • dataFld String specifying which field of a data source is bound to the element. (IE4+)

  • dataFormatAs String indicating how the element treats data supplied to it. (IE4+)

  • dataPageSize Integer indicating the “page” size for the table (used with data binding). (IE4+)

  • dataSrc String containing the source of data for data binding. (IE4+)

  • frame String specifying how the table will be framed. Values are above, below, hsides, lhs, rhs, vsides, box, and border. (IE4+, MOZ/N6+, DOM1)

  • height Specifies the height of the table. (IE4+)

  • rows[] Read-only collection of trs (table rows) in the table. (IE4+, MOZ/N6+, DOM1)

  • rules String specifying how to draw dividers between cells in the table. Values are none, groups, rows, cols, or all. (IE4+, MOZ/N6+, DOM1)

  • summary String containing a summary of the table. (IE6+, MOZ/N6+, DOM1)

  • tBodies[] Read-only collection of all tbody objects in the table. (IE4+, MOZ/N6+, DOM1)

  • tFoot Reference to the tfoot object for the table. (IE4+, MOZ/N6+, DOM1)

  • tHead Reference to the thead object for the table. (IE4+, MOZ/N6+, DOM1)

  • width Specifies the width of the table. (IE4+, MOZ/N6+, DOM1)

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.

  • createCaption() Creates a new caption object for the table if none exists and returns a reference to it. If a caption already exists, a reference to it is returned. (IE4+, MOZ/N6+, DOM1)

  • createTFoot() Creates a new tfoot object for the table if none exists and returns a reference to it. If a tfoot already exists, a reference to it is returned. (IE4+, MOZ/N6+, DOM1)

  • createTHead() Creates a new thead object for the table if none exists and returns a reference to it. If a thead already exists, a reference to it is returned. (IE4+, MOZ/N6+, DOM1)

  • deleteCaption() Deletes the table’s caption. (IE4+, MOZ/N6+, DOM1)

  • deleteRow(index) Deletes the row at index index from the table. (IE4+, MOZ/N6+, DOM1)

  • deleteTFoot() Deletes the tfoot object from the table. (IE4+, MOZ/N6+, DOM1)

  • deleteTHead() Deletes the thead object from the table. (IE4+, MOZ/N6+, DOM1)

  • insertRow([index]) Creates a new tr at index index (pushing the current occupant up one index) and returns a reference to the new tr. If index is omitted, the new row is placed at the end of the table. (IE4+, MOZ/N6+, DOM1)

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:

  • align String specifying the alignment of the object. (IE4+, MOZ/N6+, DOM1)

  • bgColor String specifying the background color of the section. (IE4+)

  • ch String containing the alignment character. (IE6+, MOZ/N6+, DOM1)

  • chOff String containing the offset at which the alignment character should be placed. (IE6+, MOZ/N6+, DOM1)

  • rows[] Read-only collection of rows (<tr> tags) contained within this section. (IE4+, MOZ/N6+, DOM1)

  • vAlign String specifying the vertical alignment of the cells, for example, "top". (IE4+, MOZ/N6+, DOM1)

Methods

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

  • deleteRow(index) Deletes the row at index index from the section. (IE4+, MOZ/N6+, DOM1)

  • deleteTFoot() Removes the tfoot object for the table if one exists. (IE4+)

  • deleteTHead() Removes the thead object for the table if one exists. (IE4+)

  • insertRow([index]) Creates a new tr at index index (pushing the current occupant up one index) and returns a reference to the new tr. If index is omitted the new row is placed at the end of the section. (IE4+, MOZ/N6+, DOM1)

  • moveRow(source, target) Moves the row at index source in the rows[] collection to the new index target. (IE5+)

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:

  • abbr String giving an abbreviation for header cells. (IE6+, MOZ/N6+, DOM1)

  • align String specifying the alignment of the element, for example, "left". (IE4+, MOZ/N6+, DOM1)

  • axis String containing a comma-delimited list of categories for table headers. (IE6+, MOZ/N6+, DOM1)

  • background String containing the URL of the background image for the cell. (IE4+)

  • bgColor String specifying the background color of the cell. (IE4+, MOZ/N6+, DOM1)

  • border String specifying the width of the border to draw around the cell. (IE4+, MOZ/N6+, DOM1)

  • borderColor String specifying the color of the border. (IE4+)

  • borderColorDark String specifying the dark border color for 3D borders. (IE4+)

  • borderColorLight String specifying the light border color for 3D borders. (IE4+)

  • cellIndex Read-only integer indicating the index of the cell in its row’s rows[] collection. (IE4+, MOZ/N6+, DOM1)

  • ch String containing the alignment character. (IE6+, MOZ/N6+, DOM1)

  • chOff String containing the offset at which the alignment character should be placed. (IE6+, MOZ/N6+, DOM1)

  • colSpan Integer indicating how many columns are spanned by this cell. (IE4+, MOZ/N6+, DOM1)

  • headers String specifying a comma-separated list of id attributes of cells that provide header information for the current cell. (IE6+, MOZ/N6+, DOM1)

  • height Specifies the height of the cell. (IE4+, MOZ/N6+, DOM1)

  • noWrap Boolean that indicates if word wrapping in the cell is suppressed. (IE4+, MOZ/N6+, DOM1)

  • rowSpan Integer indicating how many rows the cell spans. (IE4+, MOZ/N6+, DOM1)

  • scope Specifies which group of cells the current header provides information for. (IE6+, MOZ/N6+, DOM1)

  • vAlign String specifying the vertical alignment of the cell data, for example, "top". (IE4+, MOZ/N6+, DOM1)

  • width Specifies the width of the cell. (IE4+, MOZ/N6+, DOM1)

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:

  • accessKey Single character string indicating the hotkey that gives the element focus. (IE4+, MOZ/N6+, DOM1)

  • autocomplete String ("yes" or "no") indicating whether to use the browser’s AutoComplete features for this input area. (IE5+)

  • dataFld String specifying which field of a data source is bound to the element. (IE4+)

  • dataFormatAs String indicating how the element treats data supplied to it. (IE4+)

  • dataSrc String containing the source of data for data binding. (IE4+)

  • defaultValue A read-only string containing the original value attribute for the element (does not reflect changes made by the user or script). (IE3+, MOZ, N2+, DOM1)

  • disabled Boolean indicating whether the element is disabled (grayed out). (IE4+, MOZ/N6+, DOM1)

  • form A read-only reference to the Form in which the element is contained. (IE3+, N2+, MOZ, DOM1)

  • maxLength Integer indicating the maximum number of characters the field can contain. (IE4+, MOZ/N6+, DOM1)

  • name A read-only string holding the name attribute of the element. (IE3+, N2+, MOZ, DOM1)

  • readOnly Boolean indicating if the field is read-only. Like disabled, but a read-only field appears normal (not grayed out). (IE4+, MOZ/N6+, DOM1)

  • size Indicates the width of the field in characters. Defaults normally in browsers to 20. (IE4+, MOZ/N6+, DOM1)

  • tabIndex Numeric value indicating the tab order for the object. (IE4+, MOZ/N6+, DOM1)

  • type String containing the value of the type attribute, for example, "text", "hidden", or "password". (IE3+, MOZ, N3+, DOM1)

  • value String containing the text found in the field. (IE3+, MOZ, N2+, DOM1)

  • vcard_name String indicating what value from the user’s profile should be pre-filled in the input area. See MSDN for complete details. (IE5+)

Methods

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

  • blur() Removes focus from the element. (IE3+, MOZ, N2+, DOM1)

  • createTextRange() Creates a TextRange object for examination or manipulation of the input’s text. A better cross-browser solution is to use standard String methods on the field’s value. (IE4+)

  • focus() Gives focus to the element. (IE3+, MOZ, N2+, DOM1)

  • handleEvent(event) Causes the Event event to be handled by the element. (N4 only)

  • select() Selects the text contents of the field. Useful for permitting the user to quickly delete large amounts of text or for drawing attention to a particular piece of text. (IE3+, MOZ, N2+, DOM1)

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

  • accessKey Single character string indicating the hotkey that gives the element focus. (IE4+, MOZ/N6+, DOM1)

  • cols Holds the number of columns of the input area. (IE4+, MOZ/N6+, DOM1)

  • dataFld String specifying which field of a data source is bound to the element. (IE4+)

  • dataFormatAs String indicating how the element treats data supplied to it.(IE4+)

  • dataSrc String containing the source of data for data binding. (IE4+)

  • defaultValue Read-only string holding the initial value of the value attribute (does not reflect changes made by the user). (IE3+, MOZ, N2+, DOM1)

  • disabled Boolean indicating whether the element is disabled (grayed out). (IE4+ MOZ/N6+, DOM1)

  • form Read-only reference to the Form in which the textarea is embedded. (IE3+, MOZ, N2+, DOM1)

  • name String holding the name attribute of the element. (IE3+, MOZ, N2+, DOM1)

  • readOnly Boolean indicating if the field is read-only. Like disabled, but a read-only field appears normal (not grayed out). (IE4+, MOZ/N6+, DOM1)

  • rows Holds the number of rows of the input area. (IE4+, MOZ/N6+, DOM1)

  • status Indicates whether the textarea is selected. (IE4+)

  • tabIndex Numeric value indicating the tab order for the object. (IE4+, MOZ/N6+, DOM1)

  • type Read-only string containing the type of the field, in this case "textarea". (IE3+, N3+, DOM1)

  • value String holding the text currently in the textarea. Be aware that since the textarea takes returns and other special characters they will be represented within the string as escaped values. (IE3+, MOZ, N2+, DOM1)

  • wrap String specifying how word wrapping is to be performed. Values are "hard" (carriage returns are added to the text), "soft" (wrapped but no returns added, the default), or "none". (IE4+)

Methods

  • blur() Removes focus from the element. (IE3+, MOZ, N2+, DOM1)

  • createTextRange() Creates a TextRange object for examination or manipulation of the textarea’s text. A better cross-browser solution is to use standard String methods on the textarea’s value. (IE4+)

  • focus() Gives focus to the element. (IE3+, MOZ, N2+, DOM1)

  • handleEvent(event) Causes the Event event to be handled by the element. (N4 only)

  • select() Causes the contents of the text area to be selected (highlighted). (IE3+, MOZ, N2+, DOM1)

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

  • data Used to retrieve the text contents of the object. The property is readable and writable. (IE5+, MOZ/N6+, DOM1)

  • length Read-only property indicating the number of characters in the data property. (IE5+, MOZ/N6+, DOM1)

  • nextSibling Read-only reference to next sibling of the node, for example, if its parent has multiple children. (IE5+, MOZ/N6+, DOM1)

  • nodeName Read-only string containing the name of the node, for example, the name of the tag the node corresponds to (e.g., "STRONG") or, in the case of text nodes, "#text".

  • nodeType Read-only number holding the DOM defined node type. In the case of text nodes, this value is 3.

  • parentNode Read-only reference to the parent of the object (or null if none exists). (IE5+, MOZ/N6+, DOM1)

  • previousSibling Read-only reference to previous sibling of the node, for example, if its parent node has multiple children. (IE5+, MOZ/N6+, DOM1)

Methods

  • appendData(data) Appends the string data to the end of the text node. (IE6+, MOZ/N6+, DOM1)

  • deleteData(offset, count) Deletes count characters starting from index offset in the text node. (IE6+, MOZ/N6+, DOM1)

  • insertData(offset, string) Inserts the string string into the text node at character index offset. (IE6+, MOZ/N6+, DOM1)

  • replaceData(offset, count, string) Replaces count characters of the text node starting at index offset with the corresponding number of characters from the string string. (IE6+, MOZ/N6+, DOM1)

  • splitText(offset) Splits the text node into two pieces at character position offset. A new text node containing the right half of the text is returned and the corresponding text is removed from the node. (IE6+, MOZ/N6+, DOM1)

  • substringData(offset, count) Returns a string corresponding to the substring beginning at character index offset and running for count characters. (IE6+, MOZ/N6+, DOM1)

Notes

  • The document.createTextNode() method is used to create text nodes.

  • String methods can be used to manipulate the data property of text nodes.

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

  • boundingHeight Contains the height of the rectangle that bounds the TextRange object in pixels.

  • boundingLeft A read-only property containing the integer distance (in pixels) between the left edge of the rectangle that bounds the TextRange object and the left side of the object that contains the TextRange.

  • boundingTop A read-only property containing the integer distance (in pixels) between the top edge of the rectangle that bounds the TextRange object and the top side of the object that contains the TextRange.

  • boundingWidth A read-only numeric property that holds the width of the rectangle (in pixels) that bounds the TextRange object.

  • htmlText A read-only string that contains the HTML source of the range as a valid HTML fragment.

  • offsetLeft A read-only property containing the calculated left position in pixels of the object (see Generic HTML Element) relative to the layout or coordinate parent, as specified by the offsetParent property.

  • offsetTop A read-only property containing the calculated top position of the object (see Generic HTML Element) relative to the layout or coordinate parent, as specified by the offsetParent property.

  • text Read/write property that contains the text within the range.

Methods

  • collapse([start]) Moves the insertion point to the beginning or end of the current range. The optional start parameter indicates where to move the insertion point. By default (or setting start to true) it moves it to the beginning of the range. A false value moves it to the end of the range.

  • compareEndPoints(type, otherRange) Compares an end point of a TextRange object with an end point of another range specified by otherRange. The type parameter is used to indicate the type of comparison and takes a string value of "StartToEnd", "StartToStart", "EndToStart", or "EndToEnd". The method returns an integer value of –1, 0, or 1, indicating the range end is left, the same, or right of the compared range.

  • duplicate() Returns a duplicate of the TextRange.

  • execCommand(command [, userInterface] [, value]) Executes a command on the current document, current selection, or the given range. Used primarily with the MSHTML editing control. See MSDN for details.

  • expand(unit) Expands the range so that partial units are completely contained. The unit parameter is used to control expansion and takes string values of "character", "word", "sentence", or "textedit". The oddly named "textedit" value expands to cover the entire range. The method returns a Boolean value indicating success or failure.

  • findText(text,[scope],[flag]) Searches for the text in the document and positions the start and end points of the range to encompass the search string. The scope parameter indicates the number of characters to start searching from starting at the beginning of the range. The flag value can control how the matching is performed. See MSDN for details on the unusual values used for this parameter.

  • getBookmark() Retrieves a bookmark string that can be used with moveToBookmark() to return to the same range.

  • getBoundingClientRect() Retrieves an object that specifies the bounds of a collection of TextRectangle objects. The returned object has top, right, bottom, and left properties indicating the coordinates of the bounding rectangle. (IE 5+)

  • getClientRects() Retrieves a collection of rectangles that describes the layout of the contents of an object or range within the client. Each rectangle describes a single line. (IE 5+)

  • inRange(otherRange) Returns a Boolean value indicating whether one range is contained within another (otherRange).

  • isEqual(otherRange) Returns a Boolean value indicating whether the specified range (otherRange) is equal to the current range.

  • move(unit [,count]) Collapses the given text range by unit (either "character", "word", "sentence", or "textedit"). The unit value of "textedit" moves to the start or end of the range. The optional count value can indicate a positive or negative number of specified units to move. An empty range is moved by the given number of units. The method returns an integer indicating the number of units moved.

  • moveEnd(unit [,count]) Changes the end position of the given text range by unit (either "character", "word", "sentence", or "textedit"). The unit value of "textedit" moves to the start or end of the range. The optional count value can indicate a positive or negative number of specified units to move. The method returns an integer indicating the number of units moved.

  • moveStart(unit [,count]) Changes the start position of the given text range by unit (either "character", "word", "sentence", or "textedit"). The unit value of "textedit" moves to the start or end of the range. The optional count value can indicate a positive or negative number of specified units to move. The method returns an integer indicating the number of units moved.

  • moveToBookmark(bookmark) Moves to a bookmark defined by the passed bookmark string. Bookmark strings are created with the getBookmark() method. A Boolean value is used to indicate if the movement is successful.

  • moveToElementText(element) Moves the text range so that the start and end positions of the range encompass the text in the given element. (IE 5+)

  • moveToPoint(x,y) Moves the start position of the text range to the given point in the window specified by the x and y parameters. The moved range will be empty but can then be expanded.

  • parentElement() Retrieves the parent element for the given TextRange or null.

  • pasteHTML(htmlText) Pastes HTML text defined by htmlText into the given text range, replacing any previous text and HTML elements in the range.

  • queryCommandEnabled, queryCommandIndeterm, queryCommandState, queryCommandSupported, queryCommandValue These methods are related to the execCommand() method in Internet Explorer, which manipulates the MSHTML editor control. These methods indicate whether a command is allowed, enabled, and what its currents status is. See Microsoft documentation at MSDN for details on this very proprietary technology. (IE4+)

  • scrollIntoView([alignToTop]) Causes the object to be immediately scrolled into the viewable area of the window. If alignToTop is true or omitted, the top of the object is aligned with the top of the window (if possible). Otherwise, if alignToTop is false, the object is scrolled so that the bottom of the object is aligned with the bottom of the viewable window. (IE4+)

  • select() Makes the selection equal to the current object, thus highlighting the contents of the TextRange object.

  • setEndPoint(type,otherRange) Sets the endpoint of one range based on the endpoint of another range (otherRange). The type parameter indicates the end point to transfer and takes a string value of "StartToEnd", "StartToStart", "EndToStart", or "EndToEnd". The method returns an integer value of –1, 0, or 1, indicating the range is either left, the same, or right of the compared range.

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

  • bottom Contains the bottom coordinate (an integer) in pixels of the rectangle surrounding the object content.

  • left Contains the left coordinate (an integer) in pixels of the rectangle surrounding the object content.

  • right Contains the right coordinate (an integer) in pixels of the rectangle surrounding the object content.

  • top Contains the top coordinate (an integer) in pixels of the rectangle surrounding the object content.

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:

  • text String containing the title of the document, the text enclosed by the <title></title> tags. (IE4+, MOZ/N6+, DOM1)

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:

  • bgColor String specifying the background color of the row. (IE4+, MOZ/N6+, DOM1)

  • border String specifying the width of the border to draw around the row. (IE4+, MOZ/N6+, DOM1)

  • borderColor String specifying the color of the border. (IE4+)

  • borderColorDark String specifying the dark border color for 3D borders. (IE4+)

  • borderColorLight String specifying the light border color for 3D borders. (IE4+)

  • cells[] Collection of cells (td and th elements) in the row. (IE4+, MOZ/N6+, DOM1)

  • ch String containing the alignment character. (IE6+, MOZ/N6+, DOM1)

  • chOff String containing the offset at which the alignment character should be placed. (IE6+, MOZ/N6+, DOM1)

  • rowIndex Read-only integer indicating the index of the current row in its parent table’s rows[] array. (IE4+, MOZ/N6+, DOM1)

  • sectionRowIndex Integer indicating the index of the current row in its parent container’s rows[] array. A container is either a thead, tbody, or tfoot. (IE4+, MOZ/N6+, DOM1)

  • vAlign String specifying the vertical alignment of the cells, for example, "top". (IE4+, MOZ/N6+, DOM1)

Methods

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

  • deleteCell(index) Deletes the cell at index index. (IE4+, MOZ/N6+, DOM1)

  • insertCell(index) Inserts a new (empty) cell at index index (or at the end if index is –1) and returns a reference to the new td. (IE4+, MOZ/N6+, DOM1)

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:

  • compact Boolean indicating whether the list should be compacted by removing extra space between list objects. Commonly used browsers do not make this visual change. (IE4+, MOZ/N6+, DOM1)

  • type Sets the style of list bulleting: "disc", "square", or "circle". (IE3+, MOZ/N6+, DOM1)

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

  • addReadRequest(attribute) Adds an entry to the queue for read requests for the vCard property given in the string attribute. Returns a Boolean indicating if the request could be added. (IE4+)

  • clearRequest() Clears all requests from the read-request queue to clear the way for a new set of requests. (IE4+)

  • doReadRequest(usageCode [, partyName][, domain][, path]) Causes the read request queue to be processed, displaying the partyName as extra information about the party requesting the access and using the integer usageCode to notify the user how the information will be used. Values for usageCode are 0–12, and their semantics can be found at the MSDN support site. The user can selectively grant or deny access to the information requested for each item in the queue. The domain and path strings specify other domains and paths of parties that will receive the information (in addition to the current URL). (IE4+)

  • getAttribute(attribute) Returns a string containing the value of the vCard property specified by the string attribute. Access to this attribute should be requested first using addReadRequest() and doReadRequest(). Returns null if the attribute value is not available or has been denied. (IE4+)

  • setAttribute(attribute, value) Attempts to set the attribute given in the string attribute to the value in string value. (IE4+)

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 HTMLWbrElement 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

  • clientInformation Contains information about the browser configuration. (IE4+)

  • clipboardData Provides access to the OS’s clipboard. (IE5+)

  • closed This read-only Boolean value indicates whether the user has closed the window. (IE4+, MOZ, N3+, DOM0)

  • crypto Provides access to Netscape’s cryptographic methods. See documentation at Netscape or mozilla.org for more information. (N4+)

  • defaultStatus String containing the default message for the browser’s status bar. (IE3+, MOZ, N2+)

  • dialogArguments Read-only value containing the parameter specified in the second parameter of showModelDialog() or showModelessDialog(). (IE4+)

  • dialogHeight The height of the window if it was created with showModelDialog() or showModelessDialog(). Units are in em in IE4 or pixels otherwise. (IE4+)

  • dialogLeft The x coordinate of the left edge of the window if it was created with showModelDialog() or showModelessDialog(). Units are in em in IE4 or pixels otherwise. (IE4+)

  • dialogTop The y coordinate of the top edge of the window if it was created with showModelDialog() or showModelessDialog(). Units are in em in IE4 or pixels otherwise. (IE4+)

  • dialogWidth The width of the window if it was created with showModelDialog() or showModelessDialog(). Units are in em in IE4 or pixels otherwise. (IE4+)

  • directories Object with property visible, which is a Boolean indicating if Netscape’s “directories” button is visible. Requires UniversalBrowserWrite to set. (MOZ/N6+)

  • document Reference to the Document contained in the window. (IE3+, MOZ, N2+, DOM0)

  • event The Event instance that IE makes implicitly available to event handlers. (IE4+)

  • external Reference to the external object providing extended functionality. (IE4+)

  • frameElement Read-only reference to the Frame in which the window is contained. (MOZ/N6+, IE5.5+ Windows)

  • frames[] Collection of frames contained within the window. (IE3+, MOZ, N2+, DOM0)

  • fullScreen Boolean indicating if the browser is in full-screen mode (requires extended privileges to set). (N6+/MOZ)

  • history Reference to the browser’s History object. (IE3+, MOZ, N3+, DOM0)

  • innerHeight Numeric value indicating height of the window’s content area in pixels. (MOZ, N4+)

  • innerWidth Numeric value indicating the width of the window’s content area in pixels. (MOZ, N4+)

  • length A read-only value indicating the number of frames contained in the window. (IE3+, MOZ, N2+, DOM0)

  • location Reference to the Location object holding data about the document currently loaded in the window. (IE3+, MOZ, N2+, DOM0)

  • locationbar Object with property visible, a Boolean indicating if the browser’s location bar is currently visible. Requires UniversalBrowserWrite to set. (MOZ, N4+)

  • menubar Object with property visible, a Boolean indicating if the browser’s menu bar is currently visible. Requires UniversalBrowserWrite to set. (MOZ, N4+)

  • name String holding the name attribute of the window or frame. Useful for using JavaScript to determine which frame it is currently executing within or with the target attribute of links. (IE3+, MOZ, N2+, DOM0)

  • navigator Reference to the browser’s Navigator object. (IE3+, MOZ/N6+ (top-level object in earlier versions), DOM0)

  • offscreenBuffering Boolean indicating whether content is buffered before being sent to the screen. Can also take on the value "auto" in IE, which permits the browser to choose. (NS4 only, IE4+)

  • opener Reference to the Window that opened the current window. (IE3+, MOZ, N3+, DOM0)

  • outerHeight Numeric value indicating the total height of the window in pixels. (MOZ, N4+)

  • outerWidth Numeric value indicating the total width in pixels of the window. (MOZ, N4+)

  • pageXOffset Indicates how far to the right (in pixels) the window is currently scrolled. (MOZ, N4+)

  • pageYOffset Indicates how far down (in pixels) the window is currently scrolled. (MOZ, N4+)

  • parent Read-only reference to the Window or Frame that is the parent of the current frame. (IE3+, MOZ, N2+, DOM0)

  • personalbar Object with property visible, a Boolean indicating if the browser’s personal bar is currently visible. Requires UniversalBrowserWrite to set. (MOZ, N4+)

  • pkcs11 Object that provides cryptographic functionality (implementing PKCS #11). See mozilla.org for more information. (MOZ/N6+)

  • returnValue The value returned by the window (or to be returned by the window) if it was created using showModalDialog(). (IE4+)

  • screen Reference to the browser’s Screen object. (IE4+, MOZ/N6+ (top-level object in N4), DOM0)

  • screenLeft This read-only value indicates the x coordinate in pixels of the left edge of the client area of the browser window. (IE5+)

  • screenTop This read-only value indicates the y coordinate in pixels of the top edge of the client area of the browser window. (IE5+)

  • screenX Integer indicating the x coordinate of the left edge of the browser window, relative to the entire screen. Setting this property requires UniversalBrowserWrite. (MOZ, N4+)

  • screenY Integer indicating the y coordinate of the top edge of the browser window, relative to the entire screen. Setting this property requires UniversalBrowserWrite. (MOZ, N4+)

  • scrollX This read-only value indicates how far (in pixels) the window is scrolled to the right. (MOZ/N6+)

  • scrollY This read-only value indicates how far (in pixels) the window is scrolled down. (MOZ/N6+)

  • scrollbars Object with property visible, a Boolean indicating if the browser’s scrollbars are currently visible. Requires UniversalBrowserWrite to set. (MOZ, N4+)

  • self Reference to the current Window. (IE3+, MOZ, N2+, DOM0)

  • status String containing the text currently displayed in the browser’s status bar. (IE3+, MOZ, N2+, DOM0)

  • statusbar Object with property visible, a Boolean indicating if the browser’s status bar is currently visible. Requires UniversalBrowserWrite to set. (MOZ, N4+)

  • toolbar Object with property visible, a Boolean indicating if the browser’s tool bar is currently visible. Requires UniversalBrowserWrite to set. (MOZ, N4+)

  • top Read-only reference to the top Window in the document object hierarchy. Useful for accessing the enclosing Window from frames. (IE3+, MOZ, N2+, DOM0)

  • window Read-only reference to the current Window. (IE3+, MOZ, N2+, DOM0)

Methods

  • alert(message) Pops up an alert dialog box with text message and an OK button. (IE3+, MOZ, N2+, DOM0)

  • addEventListener(whichEvent, handler, direction) Instructs the window to execute the function handler whenever an event of type given in the string whichEvent (for example, "click") occurs. The direction is a Boolean specifying the phase in which to fire, true for capture or false for bubbling. (MOZ/N6+, DOM2)

  • atob(string) Base64-encodes string and returns the encoded string. (MOZ, N4+ but not present in some versions of N6)

  • attachEvent(whichHandler, theFunction) Attaches the function theFunction as a handler specified by the string whichHandler, for example, "onclick". (IE5+)

  • back() Causes the browser to load the previous URL in the top-level window’s history. (MOZ, N4+, DOM0)

  • blur() Removes focus from the browser window (IE4+, N3+, MOZ)

  • btoa(string) Base64-decodes string and returns the decoded string. (MOZ, N4+ but not present in some versions of N6)

  • captureEvents(eventMask) Instructs object to capture the events given in the bitmask eventMask. (MOZ, N4+)

  • clearInterval(intervalID) Cancels the interval intervalID (previously returned by setInterval). (IE4+, MOZ, NS4+, DOM0)

  • clearTimeout(timeoutID) Cancels the timeout timeoutID (previously returned by setTimeout). (IE3+, MOZ, N2+, DOM0)

  • close() Closes the window (subject to user approval in most browsers). (IE3+, MOZ, N2+, DOM0)

  • confirm(message) Displays a confirmation dialog box with text message and OK and Cancel buttons. Returns true if the user selects OK or false otherwise. (IE3+, MOZ, N2+, DOM0)

  • createPopup([vArgs]) Creates a pop-up window (initially hidden and empty) and returns a reference to the new popup object. The argument vArgs is not currently in use. (IE5.5+)

  • detachEvent(whichHandler, theFunction) Instructs the window to cease executing the function theFunction as a handler given the string whichHandler, for example, "onclick". (IE5+)

  • disableExternalCapture() Disables capturing of external events by scripts in the windows. Only used with signed scripts. (MOZ, N4+)

  • enableExternalCapture() Enables script in the window to capture events in other windows, no matter what their origin. Once this method is invoked, the script can listen in on other windows’ events using their captureEvents() method. This method requires UniversalBrowserWrite. (MOZ, N4+)

  • execScript(expression, language) Executes the string expression as script in the language given in string language (for example, "JScript"). (IE4+)

  • focus() Gives focus to the window. (IE4+, MOZ, N3+, DOM0)

  • forward() Causes the browser to load the next URL in the top-level window’s history. (N4+)

  • getComputedStyle(element, pseudoElement) Gets a Style object representing the totality of CSS applied to the element object element. If the string pseudoElement is passed, the CSS for the element and the given pseudo-element is returned. (MOZ/N6+, DOM2)

  • getSelection() Gets a SelectedTextRange object representing the current text selection by the user. See W3C DOM's Range API for use. (N6+/MOZ)

  • home() Causes the browser to load the user’s preferred home page. (N4+, DOM0)

  • moveBy(x, y) Moves the window x pixels horizontally and y pixels vertically from its current position. Moving it outside of the screen requires UniversalBrowserWrite in Netscape. (IE4+, MOZ, N4+)

  • moveTo(x, y) Moves the window to the absolute screen coordinates (x, y). (IE4+, MOZ, N4+)

  • navigate(url) Loads the URL given in string url into the window. (IE3+)

  • open(url, name [, features] [, replace]) Opens up a new window to the location given in string url with the name given in string name. Returns a reference to the new window. The string features specifies which window features (for example, scroll bars) the new window will have. IE permits replace, a Boolean specifying whether the new URL replaces the existing URL (if the window already exists) in the window’s history or if it is added as a new entry. If the features parameter is specified, any features not listed in it default to being turned off. The features string is a comma-separated list of "feature=value"entries where feature is any feature listed in Table B-3 and value is either yes, no, 1, or 0, controlling whether the feature is used. Using yes/no is the preferred strategy. Some features require UniversalBrowserWrite in Netscape. Full details and numerous examples showing how to open windows can be found in Chapter 12. (IE3+, MOZ, N2+, DOM0)

    Table B-3: Possible Values for the feature Entries in the features Argument to window.open()

    feature Parameter

    Value

    Description

    Example

    alwaysLowered

    yes/no

    Indicates if window should always be lowered under all other windows. Does have a security risk.

    alwaysLowered=no

    alwaysRaised

    yes/no

    Indicates if the window should always stay on top of other windows.

    alwaysRaised=no

    dependent

    yes/no

    Indicates if the spawned window is truly dependent on the parent window. Dependent windows are closed when their parents are closed, while others stay around.

    dependent=yes

    directories

    yes/no

    Should the directories button on the browser window show?

    directories=yes

    fullscreen

    yes/no

    Should the window take over the full screen? (IE only).

    fullscreen=yes

    height

    Pixel value

    Sets the height of the window, chrome
    and all.

    height=100

    hotkeys

    yes/no

    Indicates if the hotkeys for the browser (beyond browser-essential ones like Quit) should be disabled in the new window

    hotkeys=no

    innerHeight

    Pixel value

    Sets the height of the inner part of the window where the document shows.

    innerHeight=200

    innerWidth

    Pixel value

    Sets the width of the inner part of the window where the document shows.

    innerWidth=300

    left

    Pixel value

    Specifies where relative to the screen origin to place the window. IE-specific syntax; use screeny for Netscape.

    left=10

    location

    yes/no

    Specifies if the location bar should show on the window.

    location=no

    menubar

    yes/no

    Specifies if the menu bar should be shown or not.

    menubar=yes

    outerHeight

    Pixel value

    Sets the height of the outer part of the window, including the chrome.

    outerHeight=300

    outerWidth

    Pixel value

    Sets the width of the outer part of the window, including the chrome.

    outerWidth=300

    resizable

    yes/no

    Value to indicate if the user is to be able to resize the window.

    resizable=no

    screenx

    Pixel value

    Distance left in pixels from screen origin where window should be opened. This is Netscape's syntax; use left in IE.

    screenx=100

    screeny

    Pixel value

    Distance up and down from the screen origin where window should be opened. This is Netscape's syntax; use top in IE.

    screeny=300

    scrollbars

    yes/no

    Should scroll bars show?

    scrollbars=no

    status

    yes/no

    Should the status bar show?

    status=no

    titlebar

    yes/no

    Should the title bar show?

    titlebar=yes

    toolbar

    yes/no

    Should the toolbar menu be visible?

    toolbar=yes

    top

    Pixel value

    IE-specific feature to indicate position down from the top corner of the screen to position the window; use screeny for Netscape.

    top=20

    width

    Pixel value

    The width of the window. You may want to use innerWidth instead.

    width=300

    z-lock

    yes/no

    Specifies if the z-index should be set so that a window cannot change its stacking order relative to other windows even if it gains focus.

    z-lock=yes

  • print() Causes a print dialog to appear, prompting the user with printing options. (IE5+, MOZ, N4+, DOM0)

  • prompt(message [, default]) Causes a dialog to appear with text message and a text entry field initially filled with the string default. If default is omitted, "undefined" is used. Returns the string entered by the user or null if the user cancels or closes the dialog. (IE3+, MOZ, N2+, DOM0)

  • releaseEvents(eventMask) Instructs window to stop capturing the events given in the bitmask eventMask. (MOZ, N4+)

  • removeEventListener(whichEvent, handler, direction) Removes function handler as a handler for the event given in the string whichEvent (for example, "click") for the phase given by the Boolean direction. (MOZ/N6+, DOM2)

  • resizeBy(dWidth, dHeight) Grows or shrinks the window by the number of pixels given in the arguments. Negative values cause the window to shrink. The window is resized along its bottom and right edges. Netscape requires UniversalBrowserWrite to shrink the window to smaller than 100 pixels or larger than the size of the screen. (IE4+, MOZ, N4+)

  • resizeTo(width, height) Resizes the window to the size in pixels given by the arguments. The height and width give the size of the entire window, including chrome. Netscape requires UniversalBrowserWrite to shrink the window to smaller than 100 pixels or larger than the size of the screen. (IE4+, MOZ, N4+)

  • routeEvent(event) Passes the Event instance event along normally down the hierarchy. Used to decline to handle an event. (MOZ, N4+)

  • scroll(x, y) Deprecated. Scrolls the pixel location (x,y) to the upper-left corner of the window. (IE4+, MOZ, N3+)

  • scrollBy(dX, dY) Scrolls the window dX pixels horizontally and dY pixels vertically. (IE4+, MOZ, N4+)

  • scrollByLines(howMany) Scrolls the current document howMany lines. (N7+/MOZ)

  • scrollByPages(howMany) Scrolls the current document howMany pages. (N7+/MOZ)

  • scrollTo(x, y) Scrolls the window to the given coordinates. (IE4+, MOZ, N4+)

  • setActive() Sets the window to be the active window but does not give it focus. (IE5.5+)

  • setCursor(type) Changes the cursor to the type given in string type. Valid values are alias, auto, cell, context-menu, copy, count-down, count-up, count-up-down, crosshair, default, e-resize, grab, grabbing, help, move, n-resize, ne-resize, nw-resize, pointer, s-resize, se-resize, spinning, sw-resize, text, w-resize, and wait. The result of this method will vary from platform to platform. (MOZ/N6+)

  • setInterval(toExecute, ms [, arg1 [, arg2 ...]]) Starts an interval timer that executes toExecute every ms milliseconds (on a continual basis). Returns an integer identifying the interval timer (so it can later be canceled). If toExecute is a string, the optional arguments found after ms are not used and toExecute is reevaluated upon every invocation so that it can reference variables that might change between intervals. If toExecute is a reference to a function, the optional parameters argN are passed to it on every invocation. These optional parameters are not available in IE; instead, IE takes an optional third argument that is a string specifying which language to execute toExecute as (for example, "JScript"). Note that IE4 supports only string arguments for toExecute, so passing a string for this value is the preferred strategy. (IE4+, MOZ, N4+)

  • setResizable(isResizable) Deprecated. Sets whether the window is resizable according to its Boolean argument. Behavior of this method varies wildly across platforms. (N4 only)

  • setTimeout(toExecute, ms [, arg1 [, arg2 ...]]) Executes toExecute ms milliseconds in the future. Returns an integer identifying the timer (so it can later be canceled). If toExecute is a string, the optional arguments found after ms are not used and toExecute is reevaluated upon every invocation so that it can reference variables that might change between intervals. Netscape 4+ permits toExecute to be referenced to a function, and if it is, the optional parameters argN are passed to it on every invocation. IE5 also permits toExecute to be a function reference, but these optional parameters are not available; instead, IE takes an optional third argument that is a string specifying which language to execute toExecute as (for example, "JScript"). Passing a string for toExecute is the preferred strategy. (IE3+, MOZ, N2+)

  • setZOptions(position) Deprecated. Fixes the z-index of the window to a particular value. If position is "alwaysRaised", the window will appear above all other windows at all times. If it is "alwaysLowered", the window will appear below all other windows at all times. If it is "z-lock", the window’s stacking position is fixed, that is, it does not rise above other windows when activated. This method requires the UniversalBrowserWrite privilege. (N4 only)

  • showHelp(url [, contextID]) Launches a help window that loads the url. The second parameter specifies a context ID that is used to indicate the initial help position in the document. See Microsoft documentation for Microsoft HTML Help and Winhelp. (IE4+)

  • showModalDialog(url [, arguments][, features]) Creates a dialog box that keeps focus and must be addressed before any other action can occur in the browser. The url specifies the URL of the document to display and arguments defines the value set in the new window’s dialogArguments property. Returns the value of the returnValue property of the new window when it closes. The features string is a semicolon-separated list of the "feature:value" entries of the features listed in Table B-3 (for example, "help:yes;center:yes"), as provided by Microsoft's documentation. (IE4+)

  • showModelessDialog(url [, argument][, features]) Creates a dialog box that stays on top of any other browser windows. The url specifies the URL of the document to display and argument is a string that defines the value set in the new window’s dialogArguments property. Returns a reference to the new window. The features string is a semicolon-separated list of the "feature:value" entries of the features listed in Table B-4 (for example, "help:yes;center:yes"), as provided by Microsoft's documentation. (IE4+)

    Table B-4: Possible Values for Parts of the features Argument to showModalDialog and showModelessDialog

    feature:value

    Description

    dialogHeight:Height

    Sets the height of the dialog window.

    dialogLeft:XPos

    Sets the left position of the dialog window relative to the upper-left corner of the desktop.

    dialogTop:YPos

    Sets the top position of the dialog window relative to the upper-left corner of the desktop.

    dialogWidth:Width

    Sets the width of the dialog window.

    center:{ yes | no | 1 | 0 | on | off }

    Specifies whether to center the dialog window within the desktop. The default is yes.

    dialogHide:{ yes | no | 1 | 0 | on | off }

    Specifies whether the dialog window is hidden when printing or using print preview. This feature is only available when a dialog box is opened from a trusted application. The default is no.

    edge:{ sunken | raised }

    Specifies the edge style of the dialog window. The default is raised.

    help:{ yes | no | 1 | 0 | on | off }

    Specifies whether the dialog window displays the context-sensitive Help icon. The default is yes.

    resizable:{ yes | no | 1 | 0 | on | off }

    Specifies whether the dialog window has fixed dimensions. The default is no.

    scroll:{ yes | no | 1 | 0 | on | off }

    Specifies whether the dialog window displays scroll bars. The default is yes.

    status:{ yes | no | 1 | 0 | on | off }

    Specifies whether the dialog window displays a status bar. The default is yes for untrusted dialog windows and no for trusted dialog windows.

    unadorned:{ yes | no | 1 | 0 | on | off }

    Specifies whether the dialog window displays the border window chrome. This feature is only available when a dialog box is opened from a trusted application. The default is no.

  • sizeToContent() Resizes the window so that all of its contents are visible. (MOZ/N6+)

  • stop() Halts loading of the page. (N4+, MOZ, DOM0)

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

  • canHaveHTML Read-only Boolean indicating whether the element can enclose HTML markup. (IE5.5+)

  • id String holding the unique alphanumeric identifier for the element so the data island can be accessed via document.getElementById(). (IE5+)

  • isContentEditable Read-only Boolean indicating if the user can edit the element’s contents. (IE5.5+)

  • isDisabled Read-only Boolean indicating if the user can interact with the object. (IE5.5+)

  • isMultiline Read-only Boolean indicating if the content of the data island contains one or more lines. (IE5.5+)

  • parentElement Reference to the node’s parent. This is IE’s pre-DOM equivalent of parentNode. (IE5+)

  • readyState Read-only string containing the current state of the loading of XML into the data island. Values include "uninitialized", "loading", "loaded", "interactive" (not finished loading but able to respond to user actions), and "complete". Objects progress through each of these states until they have completed loading, though some objects may skip some intermediate steps (for example, pass from "uninitialized" directly to "complete"). This property is very useful in determining whether an element has completed loading. However, you should always make sure the object exists in the Document before attempting to read this property (otherwise a runtime error will be thrown because you would be attempting to read a property of an object not yet defined). Note that readyState is given by the integers 0 through 4 (with the same meaning). (IE5+)

  • scopeName Read-only string containing the XML scope for the object. (IE5+)

  • src String containing the URL of the XML file to load into the data island. (IE5+)

  • tagUrn String containing the URN of the XML Namespace for the object. (IE5+)

  • XMLDocument Points to the root of the XML Document Object Model representing the XML content in the data island. (IE5+)

Methods

  • addBehavior(url) Attaches the DHTML Behavior referenced by string url to the element. (IE5+)

  • componentFromPoint(x, y) Returns a string that gives information about the pixel coordinate (x,y) in the client window with respect to the current element. The string returned may have one of the values in the following table. The return value specifies whether the coordinate is inside of the element (""), outside of the element ("outside"), or a part of the various scrolling mechanisms that may be displayed for the element.

    Return Value

    Component at the Given Coordinate

    ""

    Component is inside the client area of the object.

    "outside"

    Component is outside the bounds of the object.

    "scrollbarDown"

    Down scroll arrow is at the specified location.

    "scrollbarHThumb"

    Horizontal scroll thumb or box is at the specified location.

    "scrollbarLeft"

    Left scroll arrow is at the specified location.

    "scrollbarPageDown"

    Page-down scroll bar shaft is at the specified location.

    "scrollbarPageLeft"

    Page-left scroll bar shaft is at the specified location.

    "scrollbarPageRight"

    Page-right scroll bar shaft is at the specified location.

    "scrollbarPageUp"

    Page-up scroll bar shaft is at the specified location.

    "scrollbarRight"

    Right scroll arrow is at the specified location.

    "scrollbarUp"

    Up scroll arrow is at the specified location.

    "scrollbarVThumb"

    Vertical scroll thumb or box is at the specified location.

    "handleBottom"

    Bottom sizing handle is at the specified location.

    "handleBottomLeft"

    Lower-left sizing handle is at the specified location.

    "handleBottomRight"

    Lower-right sizing handle is at the specified location.

    "handleLeft"

    Left sizing handle is at the specified location.

    "handleRight"

    Right sizing handle is at the specified location.

    "handleTop"

    Top sizing handle is at the specified location.

    "handleTopLeft"

    Upper-left sizing handle is at the specified location.

    "handleTopRight"

    Upper-right sizing handle is at the specified location.

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+)

  • fireEvent(handler [, event]) Causes the event handler given by the string handler to fire. If an Event instance was passed as event, the new event created reflects the properties of event. (IE5.5+)

  • getAttributeNode(name) Returns the attribute node corresponding to the attribute in the string name. (IE6+)

  • normalize() Recursively merges adjacent text nodes in the sub-tree rooted at this element. (IE6+)

  • removeAttributeNode(attribute) Removes the attribute node given by node attribute and returns the removed node. (IE6+)

  • removeBehavior(id) Removes the DHTML Behavior associated with id (previously returned by attachBehavior()) from the element. (IE4+)

  • setAttributeNode(newAttr) Adds the attribute node newAttr (replacing and returning any attribute node with the same name). (IE6+)

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
Team LiB
Previous Section Next Section


JavaScript Editor JavaScript Debugger     JavaScript Editor


©



R7