过时
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. |
过时 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
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 |
完整支持
不支持
非标。预期跨浏览器支持较差。
弃用。不要用于新网站。
文本
interface it belongs to.
文本
replaceWholeText()
splitText()
AbortController
AbortSignal
AbstractRange
Attr
ByteString
CDATASection
CSSPrimitiveValue
CSSValue
CSSValueList
CharacterData
ChildNode
注释
CustomEvent
DOMConfiguration
DOMError
DOMErrorHandler
DOMException
DOMImplementation
DOMImplementationList
DOMImplementationRegistry
DOMImplementationSource
DOMLocator
DOMObject
DOMParser
DOMPoint
DOMPointInit
DOMPointReadOnly
DOMRect
DOMString
DOMTimeStamp
DOMTokenList
DOMUserData
Document
DocumentFragment
DocumentType
元素
ElementTraversal
Entity
EntityReference
事件
EventTarget
HTMLCollection
MutationObserver
节点
NodeFilter
NodeIterator
NodeList
NonDocumentTypeChildNode
ProcessingInstruction
PromiseResolver
范围
StaticRange
TextDecoder
TextEncoder
TimeRanges
TreeWalker
TypeInfo
USVString
UserDataHandler
XMLDocument