Mozilla XUL Element and Script Reference

Contents  Quick Reference

Node

A generic DOM node. The properties and methods described below are supported by all elements. All properties, except prefix, are read only.

Properties and Methods:

appendChild ( child )     DOM0

Adds a node as the last child of this node. Returns the added node. This function can be used, for example, to add new menu items to a menu.

attributes    DOM0

Returns an array of Attr objects, one for each attribute on the element.

childNodes    DOM0

Returns an array of the child nodes of this node. For example, you could iterate over the childNodes array of a menupopup element to get each menu item.

cloneNode ( deep )     DOM0

Creates a duplicate of this node and returns it. The node is not added into the document. You'll have to do that yourself with either insertBefore or appendChild. If the argument deep is set to true, all of the child nodes (and all nodes below them) are also duplicated.

firstChild    DOM0

Returns the first child element, which will be equivalent to the first element in the childNodes array.

hasChildNodes ( )     DOM0

This function returns true if this node has any child nodes.

insertBefore ( newChild , refChild )     DOM0

Gets and sets the value of the insertbefore ( newchild , refchild ) attribute.

isSupported ( feature , version )     DOM2

Not implemented for XUL elements.

lastChild    DOM0

Returns the last child element, which will be equivalent to the last element in the childNodes array. You can find out how many child elements there are by retrieving the length of the childNodes array.

nextSibling    DOM0

Returns the node that is immediately after this node at the same level. For example, given a reference to a toolbar button, this property will return the next toolbar button. (assuming there is nothing in-between them).

nodeName    DOM0

The name of the node or element. This will be the tag name. For example, for the button element, the nodeName will be the string 'button'. If the element is not in the default namespace, the value will have the namespace prepended to it, with a colon in-between. For example, in a XUL document, an HTML element might have the nodeName 'html:div'. Constrast this property with localName, which returns the tag name without the namespace.

nodeType    DOM0

Because nodes are the subclass of most DOM objects, each is identified by a type. For elements, this value will be 1. You don't usually need to use this property unless you are creating or parsing documents.

nodeValue    DOM0

The value of the node if it has one.

normalize ( )     DOM2

Not implemented for XUL elements.

ownerDocument    DOM0

The document object that the node is contained within.

parentNode    DOM0

The parent node of this node. This property is read-only so to move a node, use insertBefore, removeChild and other related methods.

previousSibling    DOM0

Returns the node that is immediately before this node at the same level.

removeChild ( child )     DOM0

Removes a child element of this node. The removed child is returned.

replaceChild ( newChild , oldChild )     DOM0

Removes the child of this node referenced by oldChild and replaces it with the node referenced by newChild. This function returns the replaced child oldChild.