DOMCharacterData (JavaScript)

Provides methods for accessing character data.

Defined in

DOM (JavaScript)

Methods

This class inherits the methods of DOMNode (JavaScript). The methods listed below are in addition.

Method Description
appendData(str:string) : void Appends a string to the end of the data in a node.
deleteData(offset:int, count:int) : void Deletes a range of 16-bit units from the node.
getData() : string Gets the character data of a node.
getLength() : int Gets the number of 16-bit units that are available.
insertData(offset:int, str:string) : void Inserts a string at the specified 16-bit unit offset.
replaceData(offset:int, count:int, str:string) : void Replaces characters starting at the specified 16-bit unit offset with the specified string.
setData(str:string) : void Sets the character data of a node.
substringData(offset:int, count:int) : string Extracts a range of data from the node.

Usage

The CharacterData interface extends Node with a set of attributes and methods for accessing character data in the DOM. For clarity this set is defined here rather than on each object that uses these attributes and methods. No DOM objects correspond directly to CharacterData, though Text and others do inherit the interface from it. All offsets in this interface start from 0.

As explained in the DOMString interface, text strings in the DOM are represented in UTF-16, i.e. as a sequence of 16-bit units. In the following, the term 16-bit units is used whenever necessary to indicate that indexing on CharacterData is done in 16-bit units.