Toggle navigation

XML DOM replaceData() 方法

定义和用法

replaceData() 方法用指定的字符串替换 TextComment节点的字符。

语法:

CharacterData.replaceData(start,length,string)
参数描述
start必需。要把字符串插入 Text 节点或 Comment 节点的字符位置。
length必需。要替换的字符的数量。
string必需。要插入的字符串。

抛出

该方法可以抛出具有以下代码的DOMException 异常

INDEX_SIZE_ERR - 参数 startlength是负数,或length 大于 Text 节点或 Comment 节点的长度。

NO_MODIFICATION_ALLOWED_ERR - 节点是只读的,不能修改。

描述

该方法将用字符串string替换从start开始的length个字符。如果startlength 大于 Text 节点或 Comment 节点中的字符数,那么替换从 start开始到字符串结尾的所有字符。

相关页面

XML DOM 参考手册:Text.replaceData()

XML DOM 参考手册:Comment.replaceData()