Obsolete since Gecko 26 (Firefox 26 / Thunderbird 26 / SeaMonkey 2.23 / Firefox OS 1.2)
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.
When associating user data with a key on a node,
Node.setUserData
()
can also accept, in its third argument, a handler which will be called when the object is cloned, imported, deleted, renamed, or adopted. Per the specification, exceptions should not be thrown in a
UserDataHandler
. In both
document.importNode
()
and
Node.cloneNode
()
, although user data is not copied over, the handler will be called.
None.
handle (operation, key, data, src, dst)
(no return value)
This method is a callback which will be called if a node is being cloned, imported, renamed and as well, if deleted or adopted.
operation
(unsigned short) is an operation type integer (see below).
key
(
DOMString
) is the user key.
data
(
DOMUserData
) is the user data.
src
(
节点
) is the source node (
null
if being deleted).
dst
(
节点
) is the destination node (if any, or
null
).
| 常量 | 值 | 操作 |
|---|---|---|
NODE_CLONED
|
1 |
Node.cloneNode
()
|
NODE_IMPORTED
|
2 |
Document.importNode
()
|
NODE_DELETED
Unimplemented (see
bug 550400
)
|
3 | |
NODE_RENAMED
Unimplemented
|
4 |
Node.renameNode
()
|
NODE_ADOPTED
|
5 |
Document.adoptNode
()
|
(
NODE_RENAMED
is currently not supported since
Node.renameNode
()
is not supported.)
DOM Level 3 Core: UserDataHandler
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
UserDataHandler
弃用
非标
|
Chrome No | Edge No | Firefox 4 — 22 | IE ? | Opera No | Safari No | WebView Android No | Chrome Android No | Firefox Android 4 — 22 | Opera Android No | Safari iOS No | Samsung Internet Android No |
handle
弃用
非标
|
Chrome No | Edge No | Firefox 4 — 22 | IE ? | Opera No | Safari No | WebView Android No | Chrome Android No | Firefox Android 4 — 22 | Opera Android No | Safari iOS No | Samsung Internet Android No |
不支持
兼容性未知
非标。预期跨浏览器支持较差。
弃用。不要用于新网站。
UserDataHandler
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
XMLDocument