Home to Document Object Model | Up to Core
Prev Attr | Next Comment


CharacterData
Object (inherits from Node).

No DOM objects directly implement this interface -- it is extended by Text (and others).

data
Attribute (String; can raise DOMException)

data contains the data represented by this Node. (If there is a platform restriction on the length of String, then the substringData must be used to retrieve data in appropriately sized chunks.)

Exception:

NO_MODIFICATION_ALLOWED_ERR
This node is read only.

length
Attribute (read only, Number)

length records the size (in character units) of data.

appendData
Method
ECMAScript binding: appendData(arg) (arg is a String; can raise DOMException)

Same as replaceData(this.length, 0, arg) but won't raise INDEX_SIZE_ERR (obviously).

deleteData
Method
ECMAScript binding: deleteData(offset, count) (offset and count are Numbers; can raise DOMException)

Same as replaceData(offset, count, "").

insertData
Method
ECMAScript binding: insertData(offset, arg) (offset is a Number; arg is a String; can raise DOMException)

Same as replaceData(offset, 0, arg).

replaceData
Method
ECMAScript binding: replaceData(offset, count, arg) (offset and count are Numbers; arg is a String; can raise DOMException)

count character units, starting offset character units from the start of the string (i.e. zero-based), are deleted. arg is then inserted into the string at offset.

NOTE: This is how I understand the W3C specification. Other interpretations could affect all the above *Data methods. I've not yet written any code that uses this, so I don't know whether I'm right or not. Please /msg me if you know!

Exceptions:

INDEX_SIZE_ERR
offset is negative or greater than this.length.
NO_MODIFICATION_ALLOWED_ERR
This node is read only.

substringData
Method
ECMAScript binding: substringData(offset, count) (returns String; offset and count are Numbers; can raise DOMException)

Returns a String containing count character units from data, starting offset character units from the start.

Exceptions:

INDEX_SIZE_ERR
offset is negative or greater than this.length.
DOMSTRING_SIZE_ERR
count is greater than the implementation's maximum string length.

Log in or registerto write something here or to contact authors.