Custom Search

This section is devoted to reference documentation for each of the JavaScript/DOM libraries. Eventually, it will be filled out with content from other libraries as well--SVG, etc...

These documents are licensed under the Creative Commons Share-Alike License. The information in here is a combination of work from http://developer.mozilla.com, http://www.mozref.com, and http://www.aptana.com. Special thanks is given to all contributing authors.

If you would like to update or contribute to these documents, please register your interest by contacting info@aptana.com.

Document : Node

Represents an HTML or XML document.

Platform Support

IE Mozilla Netscape Opera Safari
3.0+ 1.0+ 2.0+ 7.0+ 1.0+

Constructors

Constructor Action IE Mozilla Netscape Opera Safari
Creates a new instance of a Document object.
Show Details 3.0+ 1.0+ 2.0+ 7.0+ 1.0+

Document() : Document

Creates a new instance of a Document object.

Returns
Document

Visibility
internal

Inherited Properties

Property Action IE Mozilla Netscape Opera Safari
attributes : NamedNodeMap
Attributes for an element node.
Show Details 4.0+ 1.0+ 6.0+ 7.0+ 1.0+

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/attributes.html

Remarks

This property returns a listing of all the attributes bound to this Node. Since only Element nodes support attributes, most Node types will return a null value for this property.

NamedNodeMaps are essentially the DOM-equivilant of a hash. This property provides an alternative to the specific Element.getAttribute and Element.hasAttribute methods, which are usually used when you already know which attributes an element has. For those circumstances when you want to do some automatic discovery of attributes and their values, this property provides a convenient way to iterate through the element's attributes.

This property also has the added benefit of being usable across all nodes, not just Element nodes. Therefore no checking needs to be done ahead of time to verify if a node is an Element; rather you can iterate over the attributes list, since any element that has no attributes, or any other DOM node, will have a null value for this property.

Availability

HTML DOM Level 1|HTML DOM Level 2|W3C

childNodes : NodeList
Child nodes of the current node.
Show Details 4.0+ 1.0+ 6.0+ 7.0+ 1.0+

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/children.html

Remarks

The list of nodes that are immediate children of this node. The DOM is a heirarchial structure of Node objects. This property, combined with the parentNode properties provide the basics for defining this structure. Several convenience properties are provided for accessing some frequently-used children nodes, namely the firstChild and lastChild properties.

Since the NodeList class can be referenced as an array as well as its object-oriented interface, one can easily iterate through the contents of a node using standard JavaScript for loops. Because this property is read-only, you cannot alter the NodeList to effect this node's contents. Instead, the methods for addeding and removing nodes should be used, which will result in this being updated automatically.

Availability

HTML DOM Level 1|HTML DOM Level 2|W3C

firstChild : Node
First child node of the current node.
Show Details 4.0+ 1.0+ 6.0+ 7.0+ 1.0+

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/nodetree.html

Remarks

Returns the first child node from the list of the current node's children. If this node doesn't have any children, a null value will be returned.

This is functionally equivilant to invoking node.childNodes.NodeList.item(0), though this method is much more suscinct and doesn't require any error trapping if the child node doesn't exist.

Availability

HTML DOM Level 1|HTML DOM Level 2|W3C

lastChild : Node
Last child node of the current node.
Show Details 4.0+ 1.0+ 6.0+ 7.0+ 1.0+

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/nodetree.html

Remarks

Returns the last child node from the list of the current node's children. If this node doesn't have any children, a null value will be returned.

This is functionally equivilant to invoking node.childNodes.NodeList.item(node.childNodes.NodeList.length - 1), though this method is much more suscinct and doesn't require any error trapping if the child node doesn't exist.

Availability

HTML DOM Level 1|HTML DOM Level 2|W3C

localName : String
Local part of an element or attribute name if it the node was defined with an XML Namespace.
Show Details 4.0+ 1.0+ 6.0+ 7.0+ 1.0+
Availability

HTML DOM Level 2|W3C

namespaceURI : String
URI of the namespace for an element or attribute node if the node was defined with an XML Namespace.
Show Details 4.0+ 1.0+ 6.0+ 7.0+ 1.0+
Availability

HTML DOM Level 2|W3C

Sibling node immediately after the current node.
Show Details 4.0+ 1.0+ 6.0+ 7.0+ 1.0+

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/nodetree.html

Remarks

Returns the next node to the current one within the parent node's children. If this node is the last child within it's parent, then a null value will be returned.

When working with a node, it is often useful to be able to manipulate or search the nodes surrounding it. For instance, if given a node representing a label, you might want to find the text node immediately next to it. To help with this, the nextSibling property allows you to traverse to neighboring nodes in the DOM.

Availability

HTML DOM Level 1|HTML DOM Level 2|W3C

nodeName : String
Name of the node. Same as tag name for element nodes.
Show Details 4.0+ 1.0+ 6.0+ 7.0+ 1.0+

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/aboutnodes.html

Remarks

This returns a name that represents this node's name. Depending on the type of object this is, this property will either return the name identifying this object; for instance, if this node is a Element or Attr object, then the tag or attribute name is returned. In other cases some place-holder text will be returned.

<property>nodeName</property> node-type valuesTypeleftValueleftAttr Attribute name CDATASection#cdata-sectionComment#commentDocument#documentDocumentFragment#document-fragmentDocumentType Document type name Element Tag name Entity Entity name EntityReference Name of entity referenced Notation Notation name ProcessingInstruction Target Text#text

If XML Namespaces were defined for this node and this node is a Element or Attr object (since these are the only node types that support the use of namespaces), this property returns the node name including the prefix and localName.

Returns an upper case tag name.

Availability

HTML DOM Level 1|HTML DOM Level 2|W3C

nodeType : Number
Type of node. See Remarks for valid values.
Show Details 5.5+ 1.0+ 6.0+ 7.0+ 1.0+
  • IE: IE 5.0 on Windows does not assign nodeType attributes. Fixed in IE 5.5.

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/aboutnodes.html

Remarks

This property returns an integer indicating what type of DOM Node this object represents.

Because the Node class is inherited by several other, more specific DOM objects, this property is a programmatic way of determining what an arbitrary node is, and therefore can tell the programmer how to interact with it. There are a series of constants defined in this object that can be used to refer to this property:

<property>nodeList</property> constant valuesValuerightConstantleft1ELEMENT_NODE2ATTRIBUTE_NODE3TEXT_NODE4CDATA_SECTION_NODE5ENTITY_REFERENCE_NODE6ENTITY_NODE7PROCESSING_INSTRUCTION_NODE8COMMENT_NODE9DOCUMENT_NODE10DOCUMENT_TYPE_NODE11DOCUMENT_FRAGMENT_NODE12NOTATION_NODE
Availability

HTML DOM Level 1|HTML DOM Level 2|W3C

nodeValue : String
Value of the current node.
Show Details 4.0+ 1.0+ 6.0+ 7.0+ 1.0+

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/aboutnodes.html

Remarks

This represents the value of the node. Only Attr, CDATASection, Comment, ProcessingInstruction, and Text objects can contain a value in this property. For all other types of objects this property will return null, and setting it to a different value has no effect.

Availability

HTML DOM Level 1|HTML DOM Level 2|W3C

ownerDocument : Document
Document object that contains this node.
Show Details 6.0+ 1.0+ 6.0+ 7.0+ 1.0+

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/document.html

Remarks

Refers to the Document object that this node exists in. Because a node must be created as a child of a Document, and since Node objects cannot be moved arbitrarily from one document to another (not without duplicating it), this is a way of referring to the parent document for a node so that document-wide method calls can be used for a node.

Availability

HTML DOM Level 1|HTML DOM Level 2|W3C

parentNode : Node
Parent node of the current node.
Show Details 4.0+ 1.0+ 6.0+ 7.0+ 1.0+

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/nodetree.html

Remarks

This property contains a reference to the parent node for the current node. Since the DOM is a heirarchial structure of nodes, the parentNode and childNodes properties tie the collection of nodes together.

Not all nodes can have parents however. Attr, Document, DocumentFragment, Entity and Notation objects and as such will contain a null value for this property. As well this property will be null for newly-created nodes that have yet to be added to a location within the DOM tree.

Availability

HTML DOM Level 1|HTML DOM Level 2|W3C

prefix : String
Namespace prefix for an element or attribute node if the node was defined with an XML Namespace.
Show Details 4.0+ 1.0+ 6.0+ 7.0+ 1.0+
Availability

HTML DOM Level 2|W3C

Sibling node immediately before the current node.
Show Details 4.0+ 1.0+ 6.0+ 7.0+ 1.0+

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/nodetree.html

Remarks
Returns the previous node to the current one within the parent node's children. If this node is the first child within it's parent, then a null value will be returned.
Availability

HTML DOM Level 1|HTML DOM Level 2|W3C

Properties

Property Action IE Mozilla Netscape Opera Safari
activeElement : Element
Reference to the Element that currently has focus.
No Details 4.0+ no no no no
alinkColor : String
Specifies the color of active links.
Show Details 3.0+ 1.0+ 2.0+ 7.0+ 1.0+
Remarks
Use the alink property of the tag to initially set the color of active links. To set this property, use the color properties of HTMLBodyElement to set the color in the tag.
See Also

HTMLBodyElement

Availability

HTML DOM Level 0

anchors : Array
Array of all of the Anchor objects in a document.
Show Details 3.0+ 1.0+ 2.0+ 7.0+ 1.0+
Remarks
Because the Anchors array is read-only, modify the array by adding and deleting anchor elements. Do not confuse Anchors with hypertext links.
Availability

HTML DOM Level 1

applets : Array
Array of all of the Applet objects in a document.
Show Details 4.0+ 1.0+ 3.0+ 7.0+ 1.0+
Remarks
Because the Applets array is read-only, modify the array by adding and deleting applet elements.
Availability

HTML DOM Level 1

bgColor : String
Background color of a document.
Show Details 3.0+ 1.0+ 2.0+ 7.0+ 1.0+
Remarks
Use the bgColor property of the tag to set the document background color. To set this bgColor, use the color properties of HTMLBodyElement to set the color at any time.
See Also

HTMLBodyElement

Availability

HTML DOM Level 1

body : Element
Reference to the body or frameset element.
Show Details 4.0+ 1.0+ 6.0+ 7.0+ 1.0+

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/document.html

Remarks

For additional compatibility information, see the quirksmode page:

http://www.quirksmode.org/viewport/compatibility.html

Availability

HTML DOM Level 1

charset : String
Character set of the document.
No Details 4.0+ no no no no
characterSet : String
Character set of the document.
No Details no 1.0+ 6.0+ no 1.0+
classes : Array
Array of style properties for CSS classes.
No Details no no 4.0+ no no
compatMode : Boolean
Indicates whether the document has standards-compliant mode turned on.
Show Details 6.0+ 1.75+ 7.0+ no no

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/compatmode_off.html

cookie : String
Value of the cookie that the browser has set for the document.
Show Details 3.0+ 1.0+ 2.0+ 7.0+ 1.0+
Availability

HTML DOM Level 1

defaultCharset : String
Default character set for the document.
No Details 4.0+ no no no no
designMode : String
Specifies that design mode for an HTML document is "on" or "off."
Show Details 5.0+ 1.4+ 7.0+ no no
Remarks
If design mode is on, a user can double-click the document to edit its HTML.
dir : String
Text direction of the content in the document.
Show Details 5.0+ 1.0+ 6.0+ no no

For examples, see the quirksmode test page:

http://www.quirksmode.org/dom/tests/taginfo.html

Availability

HTML DOM Level 0

doctype : DocumentType
Document Data Type (DTD) associated with this document.
Show Details