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

浏览器兼容性

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
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

图例

不支持

不支持

兼容性未知 ?

兼容性未知

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

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

弃用。不要用于新网站。

弃用。不要用于新网站。

另请参阅

元数据

  • 最后修改: