过时
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.

Node.getUserData() method returns any user DOMUserData set previously on the given node by Node.setUserData() .

Node.setUserData and Node.getUserData methods are no longer available from Web content. Element.dataset or WeakMap can be used instead.

句法

userData = someNode.getUserData(userKey);
					

参数

  • userKey is the key to choose the specific data sought for the given node. More than one key may have been assigned on a given node, containing its own value.

范例

var d = document.setUserData('key', 15, null);
console.log(document.getUserData('key')); // 15
					

规范

规范 状态 注释
DOM (文档对象模型) 3 级核心规范
The definition of 'Node.getUserData()' 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
getUserData 弃用 非标 Chrome No Edge No Firefox 1 — 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

图例

不支持

不支持

兼容性未知 ?

兼容性未知

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

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

弃用。不要用于新网站。

弃用。不要用于新网站。

另请参阅

元数据

  • 最后修改: