过时
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.

Text.replaceWholeText() method replaces the text of the node and all of its logically adjacent text nodes with the specified text. The replaced nodes are removed, including the current node, unless it was the recipient of the replacement text.

A DOMException 采用值 NO_MODIFICATION_ERR is thrown if one of the text nodes being replaced is read only.

This method returns the text node which received the replacement text, or null if the replacement text is an empty string.  The returned node is the current node unless the current node is read only, in which case the returned node is a newly created text node of the same type which has been inserted at the location of the replacement.

句法

replacementNode = textnode.replaceWholeText(content)
					

范例

See the example for the Text.wholeText 特性。

规范

规范 状态 注释
DOM (文档对象模型) 3 级核心规范
The definition of 'Text' in that specification.
过时 初始定义。

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
replaceWholeText 弃用 非标 Chrome ? — 45 Edge 12 — 79 Firefox ? — 10 IE Yes Opera ? — 32 Safari No WebView Android ? — 45 Chrome Android ? — 45 Firefox Android ? — 10 Opera Android ? — 32 Safari iOS No Samsung Internet Android ? — 5.0

图例

完整支持

完整支持

不支持

不支持

非标。预期跨浏览器支持较差。

非标。预期跨浏览器支持较差。

弃用。不要用于新网站。

弃用。不要用于新网站。

另请参阅

元数据

  • 最后修改: