JavaScript Reference

Local Navigation

Core API

Object

Description

Availability

Attr

Represents an attribute of an Element object.

4.6 or later

CDATASection

Represents a block of escaped text, such as XML fragments, source code, or other content that is otherwise interpreted as XML markup.

4.6 or later

CharacterData

Accesses character data in the DOM.

4.6 or later

Comment

Represents the contents of a comment within a document.

4.6 or later

Document

Represents the entire HTML or XML document. It acts as the root of the tree, and provides the primary access to the data of the document.

4.6 or later

DocumentFragment

A lightweight Document object, that creates or extracts only part of a document.

4.6 or later

DocumentType

Represents the doctype for a document. If a document has a doctype, it will be a reference to this object.

4.6 or later

DOMImplementation

Defines the methods for performing the operations that are independent of any particular instance of the DOM, such as creating new documents.

4.6 or later

Element

Represents an element in an HTML or XML document.

4.6 or later

Entity

Represents any entity in an XML document.

4.6 or later

EntityReference

Represents a reference to an Entity object within the document.

4.6 or later

NamedNodeMap

Represents a collection of nodes that can be accessed by name.

4.6 or later

Node

Represents a unique node within the DOM tree, and is the primary data type for the DOM.

4.6 or later

NodeList

Contains an ordered collection of nodes.

4.6 or later

Notation

Represents a notation that is declared in a DTD.

4.6 or later

ProcessingInstruction

Represents a processing instruction for an XML document.

4.6 or later

Text

Represents the text contents of an element or attribute.

4.6 or later

Object: Attr

Availability

BlackBerry Device Software version 4.6 or later

Extends

Node

The Attr object represents an attribute in an Element object.

Although Attr objects describe Element objects, they are not actually child nodes of the element they describe. Instead, attributes are treated as properties of elements, and reside outside of the DOM tree. As a result, the Node.parentNode, Node.previousSibling, and Node.nextSibling properties are null for Attr objects.

If a declaration for an attribute exists that defines a default value, but that attribute does not yet exist, the attribute is automatically created and attached to an element with the given value.

Back To Top

Attr properties

Property name

Type

Description

Status

Support level

Availability

name

DOMString

Returns the name of the attribute. The value of the name property must be unique across all attributes attached to the same Element node.

read only

DOM 2 Core

4.6 or later

ownerElement

Element

Returns the element node that this attribute is attached to. If the attribute is not yet attached to an element, the value of this property is null.

read only

DOM 2 Core

4.6 or later

specified

boolean

When true, this property indicates that the value for the attribute has been explicitly set.

If the attribute exists with a default value, this property has a value of false.

read only

DOM 2 Core

4.6 or later

value

DOMString

Specifies the value of the attribute.

writable

DOM 2 Core

4.6 or later

Back To Top

Object: CDATASection

Availability

BlackBerry Device Software version 4.6 or later

Extends

Text

The CDATASection object represents CDATA sections, which escape entire blocks of text, such as XML fragments, source code, or other content that would otherwise be interpreted as XML markup. Only the strings <![CDATA[ (which represents the start of the CDATA section) and ]]> (which represents the end) are parsed.

Although this object inherits from the Node object, Node.normalize() does not merge adjacent CDATASection nodes.

Back To Top

Object: CharacterData

Availability

BlackBerry Device Software version 4.6 or later

Extends

Node

Extended by

Comment, Text

The CharacterData object extends the Node object and can be used to access character data in the DOM. No DOM objects directly correspond to CharacterData; rather, the methods and properties are always inherited by other objects that require this functionality, such as Comment, Text, and CDATASection.

The content of this node is represented as UTF-16. CharacterData methods all work with numeric character offsets and text ranges, and manipulate ranges of text as a sequence of 16-bit units. Before invoking these methods, you should already know the ranges that you are manipulating.

Back To Top

CharacterData properties

Property name

Type

Description

Status

Support level

Availability

data

DOMString

Specifies the character data of the current node.

writable

DOM 2 Core

4.6 or later

length

int

Returns the length of the content of the data property or the CharacterData.substringData() method.

read only

DOM 2 Core

4.6 or later

Back To Top

CharacterData methods

Method name

Description

Support level

Availability

appendData()

Appends the given string to the end of the data of the node.

DOM 2 Core

4.6 or later

deleteData()

Removes the specified range of data.

DOM 2 Core

4.6 or later

insertData()

Inserts a string at the specified location in the data.

DOM 2 Core

4.6 or later

replaceData()

Replaces the specified range of data with the given string.

DOM 2 Core

4.6 or later

substringData()

Returns the specified range of data from the node.

DOM 2 Core

4.6 or later

Back To Top

Object: Comment

Availability

BlackBerry Device Software version 4.6 or later

Extends

CharacterData

The Comment object inherits from the CharacterData object and represents the content of a comment, which begins with <!-- and ends with -->. The contents of this node include any characters that exist between those two markers.

Back To Top

Object: Document

Availability

BlackBerry Device Software version 4.6 or later

Extends

Node

The Document object represents the entire HTML or XML document. It acts as the root of the tree, and provides the primary access to the data of the document.

Back To Top

Document properties

Property name

Type

Description

Status

Support level

Availability

defaultView

AbstractView

Returns the default view of the document.

read only

DOM 2 Views

4.6 or later

doctype

DocumentType

Returns the document type declaration associated with the document.

read only

DOM 2 Core

4.6 or later

documentElement

Element

Returns the root element in a document.

read only

DOM 2 Core

4.6 or later

implementation

DOMImplementation

Returns the DOMImplementation object that handles this document.

read only

DOM 2 Core

4.6 or later

parentWindow

Window

Returns a reference to the parent window. If no parent window exists, this property points to the current active window.

read only

Not defined in any specification.

4.6 or later

styleSheets

StyleSheetList

Returns an array of all the style sheets in the document.

read only

DOM 2 Style

4.6 or later

Back To Top

Document methods

Method name

Description

Support level

Availability

adoptNode()

Adopts a node and its children from an external document to the current document.

DOM 3 Core

4.7.1 or later

createAttribute()

Creates a new Attr object with the given name.

DOM 2 Core

4.6 or later

createAttributeNS()

Creates a new Attr object with the given qualified name and namespace URI.

DOM 2 Core

4.6 or later

createCDATASection()

Creates a new CDATASection object, which represents a block of uninterpreted content.

DOM 2 Core

4.6 or later

createComment()

Creates a new Comment object with the given text as content.

DOM 2 Core

4.6 or later

createDocumentFragment()

Creates an empty DocumentFragment object.

DOM 2 Core

4.6 or later

createElement()

Creates a new Element object of the specified type.

DOM 2 Core

4.6 or later

createElementNS()

Creates a new Element object of the given qualified name and namespace URI.

DOM 2 Core

4.6 or later

createEntityReference()

Creates a new EntityReference object with the given name.

DOM 2 Core

4.6 or later

createEvent()

Creates a new Event object of the given type.

DOM 2 Core

4.6 or later

createNodeIterator()

Creates a new NodeIterator object, which you can use to iterate through a set of Document nodes rooted at the given node.

DOM 2 Traversal

4.6 or later

createProcessingInstruction()

Creates a new ProcessingInstruction object with the given name and data.

DOM 2 Core

4.6 or later

createRange()

Creates a new Range object.

DOM 2 Range

4.7.1 or later

createTextNode()

Creates a new Text node containing the given text.

DOM 2 Core

4.6 or later

createTreeWalker()

Creates a TreeWalker object, which you can use to traverse the specified document subtree.

DOM 2 Traversal

4.6 or later

getElementById()

Returns the element node with the given ID value.

DOM 2 Core

4.6 or later

getElementsByTagName()

Returns a NodeList object that contains an array of a document’s descendent element nodes with the specified tag name.

DOM 2 Core

4.6 or later

getElementsByTagNameNS()

Returns a NodeList object that contains an array of a document’s descendent element nodes with the given local name and namespace URI.

DOM 2 Core

4.6 or later

getOverrideStyle()

Retrieves the override CSSStyleDeclaration object for the given element.

DOM 2 Style

4.6 or later

importNode()

Imports a node from a different document.

DOM 2 Core

4.6 or later

querySelector()

Returns the first element within the subtree of the Document node that matches the specified selectors.

DOM 1 Selector

5.0 or later

querySelectorAll()

Finds the elements within the subtree of the Document node that match the specified selectors, and returns them as a NodeList object.

DOM 1 Selector

5.0 or later

Back To Top

Object: DocumentFragment

Availability

BlackBerry Device Software version 4.6 or later

Extends

Node

The DocumentFragment object is a lightweight Document object, used to create or extract only a portion of a document.

A DocumentFragment behaves like a conventional Node object, except that it does not need to be fully formed.

The Range object uses DocumentFragment objects extensively, so that it can extract and store ranges of DOM nodes without creating an entirely new document.

When the children of a DocumentFragment object are inserted into a Document object, only the children of the DocumentFragment, and not the DocumentFragment itself, are inserted into the node.

Back To Top

DocumentFragment methods

Method name

Description

Support level

Availability

querySelector()

Returns the first element within the subtree of the DocumentFragment object that matches the specified selectors.

DOM 1 Selector

5.0 or later

querySelectorAll()

Finds the elements within the subtree of the DocumentFragment object that match the specified selectors, and returns them as a NodeList object.

DOM 1 Selector

5.0 or later

Back To Top

Object: DocumentType

Availability

BlackBerry Device Software version 4.6 or later

Extends

Node

The DocumentType object represents the doctype for a document. If a document has a doctype, it will be a reference to this object.

Back To Top

DocumentType properties

Property name

Type

Description

Status

Support level

Availability

entities

NamedNodeMap

Returns a list of all the general entities defined within the DTD.

read only

DOM 2 Core

4.6 or later

internalSubset

DOMString

Returns the contents of the DTD subset. Contains the string between the “[“ and “]” characters.

read only

DOM 2 Core

4.6 or later

name

DOMString

Returns the name of the DTD.

read only

DOM 2 Core

4.6 or later

notations

NamedNodeMap

Returns a list of all the notations defined within the DTD.

read only

DOM 2 Core

4.6 or later

publicId

DOMString

Returns the public identifier of the external subset.

read only

DOM 2 Core

4.6 or later

systemId

DOMString

Returns the system identifier of the external subset.

read only

DOM 2 Core

4.6 or later

Back To Top

Object: DOMException

Availability

BlackBerry Device Software version 4.6 or later

The DOMException object represents an error which prevents an operation from completing.

Back To Top

Object: DOMImplementation

Availability

BlackBerry Device Software version 4.6 or later

The DOMImplementation object defines methods for performing operations that are independent of any particular instance of the DOM, such as creating new documents. You can check the object to determine if the DOMImplementation supports a given feature.

Back To Top

DOMImplementation methods

Method name

Description

Support level

Availability

createCSSStyleSheet()

Creates a new CSS stylesheet document object.

DOM 2 Style

4.6 or later

createDocument()

Creates a new XML or HTML document object.

DOM 2 Core

4.6 or later

createDocumentType()

Creates an empty document type node.

DOM 2 Core

4.6 or later

hasFeature()

Determines whether the DOM implementation implements a specific feature.

DOM 2 Core

4.6 or later

Back To Top

Object: Element

Availability

BlackBerry Device Software version 4.6 or later

Extends

Node

Extended by

HTMLElement

The Element object represents an element in an HTML or XML document. Elements may have attributes associated with them. You can use the Node.attributes property to retrieve a map of all the attributes attached to the element.

This object provides several methods for handling all the available attributes, individual attribute values, or individual Attr objects.

Back To Top

Element properties

Property name

Type

Description

Status

Support Level

Availability

tagName

DOMString

The name of the element.

read only

DOM 2 Core

4.6 or later

Back To Top

Element methods

Method name

Description

Support level

Availability

getAttribute()

Retrieves the value of the attribute of the given name.

DOM 2 Core

4.6 or later

getAttributeNode()

Retrieves the attribute node of the given name.

DOM 2 Core

4.6 or later

getAttributeNodeNS()

Retrieves the attribute node with the given namespace URI and local name.

DOM 2 Core

4.6 or later

getAttributeNS()

Retrieves the value of the attribute with the given namespace URI and local name.

DOM 2 Core

4.6 or later

getElementsByTagName()

Returns a NodeList object that contains an array of an element’s descendent element nodes with the specified tag name.

DOM 2 Core

4.6 or later

getElementsByTagNameNS()

Returns a NodeList object that contains an array of an element’s descendent element nodes with the given local name and namespace URI.

DOM 2 Core

4.6 or later

hasAttribute()

Determines whether an attribute of the given name is specified on the element.

DOM 2 Core

4.6 or later

hasAttributeNS()

Determines whether an attribute of the given namespace and local name is specified on the element.

DOM 2 Core

4.6 or later

querySelector()

Returns the first element within the subtree of the current Element node that matches the specified selectors.

DOM 1 Selector

5.0 or later

querySelectorAll()

Finds elements within the subtree of the current Element that match the specified selectors, and returns them as a NodeList object.

DOM 1 Selector

5.0 or later

removeAttribute()

Removes the attribute of the given name from the element node.

DOM 2 Core

4.6 or later

removeAttributeNode()

Removes the specified attribute node from the element node.

DOM 2 Core

4.6 or later

removeAttributeNS()

Removes the attribute node with the given namespace URI and local name from the element node.

DOM 2 Core

4.6 or later

setAttribute()

Adds a new attribute to an element, and sets it to the given value.

DOM 2 Core

4.6 or later

setAttributeNode()

Adds a new attribute node to an element.

DOM 2 Core

4.6 or later

setAttributeNodeNS()

Adds a new attribute node to an element.

DOM 2 Core

4.6 or later

setAttributeNS()

Adds a new attribute to an element, and sets it to the given value.

DOM 2 Core

4.6 or later

Back To Top

Object: Entity

Availability

BlackBerry Device Software version 4.6 or later

Extends

Node

The Entity object represents any entity in an XML document. Entities are declarations of abbreviated text or other nodes within an XML document, which can be inserted at various places in an XML document using EntityReference objects.

The Entity name is stored in the Node.nodeName property. However, the actual content of the entity is contained within the Entity node’s children. An Entity node has no parent; the Node.parentNode property for an entity will always be null.

Entity nodes and their children are read only and can not be modified once they have been added to a document. If you need to change the content of an Entity object, you must create a new one, then update all the EntityReference objects that referred to the old Entity so that they refer to the new Entity instead.

Back To Top

Entity properties

Property name

Type

Description

Status

Support level

Availability

notationName

DOMString

The name of the notation for an unparsed entity. For parsed entities, the value of this property is null.

read only

DOM 2 Core

4.6 or later

publicId

DOMString

The public identifier associated with the entity.

read only

DOM 2 Core

4.6 or later

systemId

DOMString

The system identifier associated with this entity.

read only

DOM 2 Core

4.6 or later

Back To Top

Object: EntityReference

Availability

BlackBerry Device Software version 4.6 or later

Extends

Node

The EntityReference object represents references to Entity objects within the document. An EntityReference is a node within the DOM tree that copies the children of the referenced Entity object.

The children of EntityReferences are read only and cannot be modified once they are added to a document.

Back To Top

Object: NamedNodeMap

Availability

BlackBerry Device Software version 4.6 or later

The NamedNodeMap object represents collections of nodes that can be accessed by name.

You can access an individual node within a collection by its index position using NamedNodeMap.item(), by its name or id attribute using NamedNodeMap.getNamedItem(), or you can index the object directly. For example, if you create an instance of a NamedNodeMap object called myNamedNodeMap, then specifying

myNamedNodeMap.item(2)

myNamedNodeMap.getNamedItem(“item”)

is equivalent to specifying

myNamedNodeMap[2]

myNamedNodeMap[“item”]

Back To Top

NamedNodeMap properties

Property name

Type

Description

Status

Support level

Availability

length

unsigned long

Returns the number of nodes in the map.

read only

DOM 2 Core

4.6 or later

Back To Top

NamedNodeMap methods

Method name

Description

Support level

Availability

getNamedItem()

Retrieves the node with the given name.

DOM 2 Core

4.6 or later

getNamedItemNS()

Retrieves the node with the given name and namespace URI.

DOM 2 Core

4.6 or later

item()

Returns the node at the given index in the map.

DOM 2 Core

4.6 or later

removeNamedItem()

Removes the node with the given name from the map.

DOM 2 Core

4.6 or later

removeNamedItemNS()

Removes the node with the given name and namespace URI from the map.

DOM 2 Core

4.6 or later

setNamedItem()

Adds a node using the Node.nodeName attribute.

DOM 2 Core

4.6 or later

setNamedItemNS()

Adds a node using the Node.nodeName attribute and the namespace URI.

DOM 2 Core

4.6 or later

Back To Top

Object: Node

Availability

BlackBerry Device Software version 4.6 or later

Extended by

Attr, CharacterData, Document, DocumentFragment, DocumentType, Element, Entity, EntityReference, Notation, ProcessingInstruction

The Node object represents a unique node within the DOM tree. It is the primary data type for the DOM.

While Node exposes methods for dealing with children, not all objects inheriting from Node may have children. For example, Text nodes do not permit children; trying to add children to such nodes results in a DOMException being raised.

The Node.nodeName, Node.nodeValue, and Node.nodeType properties enable you to acquire node information without casting down to the specific child object. In cases where there is no obvious mapping of these properties for a specific nodeType (for example, the Node.nodeValue for an Element, or attributes for a Comment), they return null.

The specialized objects may contain additional and more convenient mechanisms to get and set the relevant information.

Back To Top

Node properties

Property name

Type

Description

Status

Support level

Availability

attributes

NamedNodeMap

Returns a NamedNodeMap object that contains the attributes of the given element node, or null, if the node is not an element.

read only

DOM 2 Core

4.6 or later

childNodes

NodeList

Returns a NodeList object that contains all the child elements of the given node.

read only

DOM 2 Core

4.6 or later

firstChild

Node

Returns the first child of the given node.

read only

DOM 2 Core

4.6 or later

lastChild

Node

Returns the last child of the given node.

read only

DOM 2 Core

4.6 or later

localName

DOMString

Returns the local part of the qualified name for the given node.

read only

DOM 2 Core

4.6 or later

namespaceURI

DOMString

Returns the namespace URI for the given node, or null if it is not specified.

read only

DOM 2 Core

4.6 or later

nextSibling

Node

Returns the node immediately following the given node.

read only

DOM 2 Core

4.6 or later

nodeName

DOMString

Returns the name of the given node.

read only

DOM 2 Core

4.6 or later

nodeType

unsigned short

Returns a code representing the type of the given node.

read only

DOM 2 Core

4.6 or later

nodeValue

DOMString

Specifies the value of the given node.

writable

DOM 2 Core

4.6 or later

ownerDocument

Document

Returns the Document object associated with the given node.

read only

DOM 2 Core

4.6 or later

parentNode

Node

Returns the parent of the given node.

read only

DOM 2 Core

4.6 or later

prefix

DOMString

Specifies the prefix, extracted from the qualified name of the given node, or null if it is unspecified.

writable

DOM 2 Core

4.6 or later

previousSibling

Node

Returns the node immediately preceding the current node.

read only

DOM 2 Core

4.6 or later

Back To Top

Node methods

Method name

Description

Support level

Availability

addEventListener()

Adds an EventListener object to a set of event listeners for the given node.

DOM 2 Events

4.6 or later

appendChild()

Adds a node to the end of the array of child nodes for the given node.

DOM 2 Core

4.6 or later

cloneNode()

Returns a duplicate of the given node. The duplicate node has no parent.

DOM 2 Core

4.6 or later

dispatchEvent()

Dispatches an Event object.

DOM 2 Events

4.6 or later

hasAttributes()

Returns whether the given node has any attributes.

DOM 2 Core

4.6 or later

hasChildNodes()

Returns whether the given node has any children.

DOM 2 Core

4.6 or later

insertBefore()

Inserts a new node before the given node.

DOM 2 Core

4.6 or later

isSupported()

Tests whether the given node supports a specific feature.

DOM 2 Core

4.6 or later

normalize()

Merges text nodes adjacent to the given element node to create a normalized DOM.

DOM 2 Core

4.6 or later

removeChild()

Removes the specified child from the given element node and returns it.

DOM 2 Core

4.6 or later

removeEventListener()

Removes an event listener from an EventTarget.

DOM 2 Events

4.6 or later

replaceChild()

Removes the specified child from the given and replaces it with another node, then returns the removed node.

DOM 2 Core

4.6 or later

Back To Top

Object: NodeList

Availability

BlackBerry Device Software version 4.6 or later

The NodeList object is an array that contains an ordered collection of nodes.

You can access an individual Node within a collection by its index position using NodeList.item() or you can index the object directly. For example, if you create an instance of a NodeList object called myNodeList, then specifying

myNodelist.item(2)

is equivalent to specifying

myNodelist[2]

Back To Top

NodeList properties

Property name

Type

Description

Status

Support level

Availability

length

unsigned long

Returns the number of Nodes in the list.

read only

DOM 2 Core

4.6 or later

Back To Top

NodeList methods

Method name

Description

Support level

Availability

item()

Returns the Node at the specified index in the collection.

DOM 2 Core

4.6 or later

Back To Top

Object: Notation

Availability

BlackBerry Device Software version 4.6 or later

Extends

Node

The Notation object represents a notation declared in a DTD. A Notation declares the format of an unparsed entity, or is used to formally declare ProcessingInstruction targets.

The Node.nodeName property is set to the declared name of the Notation.

Back To Top

Notation properties

Property name

Type

Description

Status

Support level

Availability

publicId

DOMString

Returns the public identifier of the Notation, or null if no identifier has been specified.

read only

DOM 2 Core

4.6 or later

systemId

DOMString

Returns the system identifier of the Notation, or null if no identifier has been specified.

read only

DOM 2 Core

4.6 or later

Back To Top

Object: ProcessingInstruction

Availability

BlackBerry Device Software version 4.6 or later

Extends

Node

The ProcessingInstruction object represents a Processing Instruction for an XML document, which enables you to keep processor-specific information within the context of the document. Processing instructions are specified within the <? and ?> markers.

For instance, instructions on which style sheets to apply can be defined in a processing instruction, even though that is not directly related to the content of the document.

Back To Top

ProcessingInstruction properties

Property name

Type

Description

Status

Support level

Availability

data

DOMString

Specifies the content of the processing instruction. This content includes everything contained between the processing instruction markers.

writable

DOM 2 Core

4.6 or later

sheet

DOMString

Returns the style sheet associated with the processing instruction.

read only

DOM 2 Events

4.6 or later

target

DOMString

Returns the target of the processing instruction.

read only

DOM 2 Core

4.6 or later

Back To Top

Object: Text

Availability

BlackBerry Device Software version 4.6 or later

Extends

CharacterData

The Text object represents the textual content of an element or attribute. If an element contains no child elements, any text is contained in a single text node in the DOM.

Although it is possible to place multiple text objects are adjacent to one another in a document, adjacent text nodes have no meaning in a document. Hence, using Text.splitText() has no visual effect on the document unless one of the nodes is wrapped by an element.

Back To Top

Text methods

Method name

Description

Support level

Availability

splitText()

Breaks the node into two nodes at the specified offset location.

DOM 2 Core

4.6 or later

Back To Top
Previous topic: Properties

Was this information helpful? Send us your comments.