这篇翻译不完整。请帮忙从英语翻译这篇文章。
CharacterData 抽象接口(abstract interface)代表 Node 对象包含的字符。这是一个抽象接口,意味着没有 CharacterData 类型的对象。 它是在其他接口中被实现的,如 Text、Comment 或 ProcessingInstruction 这些非抽象接口。
属性
从其父级 Node 继承属性,并且实现了 ChildNode 和 NonDocumentTypeChildNode 接口。
-
CharacterData.data -
一个
DOMString,表示该对象中包含的文本数据。 -
CharacterData.length只读 -
返回一个
unsigned long的表示CharacterData.data包含的字符串的大小。 -
NonDocumentTypeChildNode.nextElementSibling只读 -
返回其父节点所在的子节点列表(children list)中紧跟着的元素节点
Element,或者null。 -
NonDocumentTypeChildNode.previousElementSibling只读 -
返回其父节点所在的子节点列表(children list)中前一个元素节点
Element,或者null。
方法
Inherits methods from its parent, Node, and implements the ChildNode and NonDocumentTypeChildNode interface.
-
CharacterData.appendData() -
Appends the given
DOMStringto theCharacterData.datastring; when this method returns,datacontains the concatenatedDOMString. -
CharacterData.deleteData() -
Removes the specified amount of characters, starting at the specified offset, from the
CharacterData.datastring; when this method returns,datacontains the shortenedDOMString. -
CharacterData.insertData() -
Inserts the specified characters, at the specified offset, in the
CharacterData.datastring; when this method returns,datacontains the modifiedDOMString. -
ChildNode.remove() - Removes the object from its parent children list.
-
CharacterData.replaceData() -
Replaces the specified amount of characters, starting at the specified offset, with the specified
DOMString; when this method returns,datacontains the modifiedDOMString. -
CharacterData.substringData() -
Returns a
DOMStringcontaining the part ofCharacterData.dataof the specified length and starting at the specified offset.
规范
| Specification | Status | Comment |
|---|---|---|
| DOM CharacterData |
Living Standard | Added implemention of the ChildNode and NonDocumentTypeChildNode interface. |
| Document Object Model (DOM) Level 3 Core Specification CharacterData |
Recommendation | No change from Document Object Model (DOM) Level 2 Core Specification. |
| Document Object Model (DOM) Level 2 Core Specification CharacterData |
Recommendation | No change from Document Object Model (DOM) Level 1 Specification. |
| Document Object Model (DOM) Level 1 Specification CharacterData |
Recommendation | Initial definition. |
浏览器兼容性
| Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|
| Basic support | 1.0 | 1.0 (1.7 or earlier) | 6 | (Yes) | (Yes) |
Implements ChildNode interface. |
? | 25.0 (25.0) [1] | 未实现 | ? | 未实现 |
| Feature | Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|
| Basic support | (Yes) | 1.0 (1.0) | (Yes) | (Yes) | (Yes) |
Implements ChildNode interface. |
? | 25.0 (25.0) [1] | 未实现 | ? | 未实现 |
[1] Two properties, nextElementSibling and previousElementSibling, have been moved to the NonDocumentTypeChildNode interface, also implemented by CharacterData.

