diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/node/getuserdata | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/zh-cn/web/api/node/getuserdata')
-rw-r--r-- | files/zh-cn/web/api/node/getuserdata/index.html | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/node/getuserdata/index.html b/files/zh-cn/web/api/node/getuserdata/index.html new file mode 100644 index 0000000000..cc81f8c288 --- /dev/null +++ b/files/zh-cn/web/api/node/getuserdata/index.html @@ -0,0 +1,96 @@ +--- +title: Node.getUserData() +slug: Web/API/Node/getUserData +translation_of: Web/API/Node/getUserData +--- +<p>{{ APIRef }}{{ obsolete_header() }}</p> +<p>The <code><strong>Node.getUserData()</strong></code> method returns any user {{domxref("DOMUserData")}} set previously on the given node by {{domxref("Node.setUserData()")}}.</p> +<div class="note"> + <p>The <code>Node.setUserData</code> and {{domxref("Node.getUserData")}} methods are no longer available from Web content. {{domxref("Element.dataset")}} or <a href="/en-US/docs/JavaScript/Reference/Global_Objects/WeakMap"><code>WeakMap</code></a> can be used instead.</p> +</div> +<h2 id="Syntax">Syntax</h2> +<pre class="syntaxbox"><em>userData</em> = <em>someNode</em>.getUserData(<em>userKey</em>);</pre> +<h3 id="Parameters">Parameters</h3> +<ul> + <li><code>userKey</code> 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.</li> +</ul> +<h2 id="Example">Example</h2> +<pre class="brush: js">var d = document.setUserData('key', 15, null); +alert(document.getUserData('key')); // 15</pre> +<h2 id="Specifications">Specifications</h2> +<table class="standard-table"> + <thead> + <tr> + <th scope="col">Specification</th> + <th scope="col">Status</th> + <th scope="col">Comment</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{SpecName('DOM WHATWG', '#interface-node', 'Node')}}</td> + <td>{{Spec2('DOM WHATWG')}}</td> + <td>Removed from the specification.</td> + </tr> + <tr> + <td>{{SpecName('DOM3 Core', 'core.html#Node3-getUserData', 'Node.getUserData()')}}</td> + <td>{{Spec2('DOM3 Core')}}</td> + <td>Initial definition.</td> + </tr> + </tbody> +</table> +<h2 id="Browser_compatibility">Browser compatibility</h2> +<p>{{CompatibilityTable}}</p> +<div id="compat-desktop"> + <table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Chrome</th> + <th>Firefox (Gecko)</th> + <th>Internet Explorer</th> + <th>Opera</th> + <th>Safari</th> + </tr> + <tr> + <td>Basic support</td> + <td>{{CompatNo}}</td> + <td>Supported from {{CompatGeckoDesktop("1.0")}} to {{CompatGeckoDesktop("21.0")}}.<br> + Removed in {{CompatGeckoDesktop("22.0")}} [1]</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + </tr> + </tbody> + </table> +</div> +<div id="compat-mobile"> + <table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Android</th> + <th>Firefox Mobile (Gecko)</th> + <th>IE Mobile</th> + <th>Opera Mobile</th> + <th>Safari Mobile</th> + </tr> + <tr> + <td>Basic support</td> + <td>{{CompatNo}}</td> + <td>Supported from {{CompatGeckoMobile("1.0")}} to {{CompatGeckoMobile("21.0")}}.<br> + Removed in {{CompatGeckoMobile("22.0")}} [1]</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + </tr> + </tbody> + </table> +</div> +<p>[1] The method is still available from chrome scripts.</p> +<h2 id="See_also">See also</h2> +<ul> + <li>{{domxref("Node.setUserData()")}}</li> + <li>{{domxref("UserDataHandler")}}</li> + <li>{{domxref("DOMUserData")}}</li> +</ul> |