aboutsummaryrefslogtreecommitdiff
path: root/files/fr/web/api/node/localname/index.html
blob: ea563ffab18c8d5ab7809ff3c3253d156a9a5191 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
---
title: element.localName
slug: Web/API/Node/localName
tags:
  - API
  - DOM
  - Noeuds
  - Nom local
  - Propriétés
translation_of: Web/API/Node/localName
---
<p>{{APIRef("DOM")}}{{obsolete_header}}</p>

<p>La propriété en lecture seule <code><strong>Node.localName</strong></code> renvoie la partie locale du nom qualifié de ce nœud.</p>

<div class="warning">
<p>Dans DOM4, cette API a été déplacée de <code>Node</code> vers les interfaces {{domxref("Element")}} et {{domxref("Attr")}}.</p>
</div>

<h2 id="Syntaxe" name="Syntaxe">Syntaxe</h2>

<pre class="syntaxbox"><var>name</var> = <var>element</var>.localName
</pre>

<ul>
 <li><code>name</code> est le nom local sous la forme d'une chaîne (voir {{ Anch("Notes") }} plus bas pour plus de détails)</li>
</ul>

<h2 id="Exemple" name="Exemple">Exemple</h2>

<p>(Doit être servi avec un type de contenu XML, comme <code>text/xml</code> ou <code>application/xhtml+xml</code> .)</p>

<pre class="brush:xml line-numbers  language-xml"><code class="language-xml"><span class="tag token"><span class="tag token"><span class="punctuation token">&lt;</span>html</span> <span class="attr-name token">xmlns</span><span class="attr-value token"><span class="punctuation token">=</span><span class="punctuation token">"</span>http://www.w3.org/1999/xhtml<span class="punctuation token">"</span></span>
      <span class="attr-name token"><span class="namespace token">xmlns:</span>svg</span><span class="attr-value token"><span class="punctuation token">=</span><span class="punctuation token">"</span>http://www.w3.org/2000/svg<span class="punctuation token">"</span></span><span class="punctuation token">&gt;</span></span>
<span class="tag token"><span class="tag token"><span class="punctuation token">&lt;</span>head</span><span class="punctuation token">&gt;</span></span>
  <span class="tag token"><span class="tag token"><span class="punctuation token">&lt;</span>script</span> <span class="attr-name token">type</span><span class="attr-value token"><span class="punctuation token">=</span><span class="punctuation token">"</span>application/javascript<span class="punctuation token">"</span></span><span class="punctuation token">&gt;</span></span><span class="cdata token">&lt;![CDATA[
  function test() {
    var text = document.getElementById('text');
    var circle = document.getElementById('circle');

    text.value = "&lt;svg:circle&gt; has:\n" +
                 "localName = '" + circle.localName + "'\n" +
                 "namespaceURI = '" + circle.namespaceURI + "'";
  }
  ]]&gt;</span><span class="tag token"><span class="tag token"><span class="punctuation token">&lt;/</span>script</span><span class="punctuation token">&gt;</span></span>
<span class="tag token"><span class="tag token"><span class="punctuation token">&lt;/</span>head</span><span class="punctuation token">&gt;</span></span>
<span class="tag token"><span class="tag token"><span class="punctuation token">&lt;</span>body</span> <span class="attr-name token">onload</span><span class="attr-value token"><span class="punctuation token">=</span><span class="punctuation token">"</span>test()<span class="punctuation token">"</span></span><span class="punctuation token">&gt;</span></span>
  <span class="tag token"><span class="tag token"><span class="punctuation token">&lt;</span><span class="namespace token">svg:</span>svg</span> <span class="attr-name token">version</span><span class="attr-value token"><span class="punctuation token">=</span><span class="punctuation token">"</span>1.1<span class="punctuation token">"</span></span>
    <span class="attr-name token">width</span><span class="attr-value token"><span class="punctuation token">=</span><span class="punctuation token">"</span>100px<span class="punctuation token">"</span></span> <span class="attr-name token">height</span><span class="attr-value token"><span class="punctuation token">=</span><span class="punctuation token">"</span>100px<span class="punctuation token">"</span></span>
    <span class="attr-name token">viewBox</span><span class="attr-value token"><span class="punctuation token">=</span><span class="punctuation token">"</span>0 0 100 100<span class="punctuation token">"</span></span><span class="punctuation token">&gt;</span></span>
    <span class="tag token"><span class="tag token"><span class="punctuation token">&lt;</span><span class="namespace token">svg:</span>circle</span> <span class="attr-name token">cx</span><span class="attr-value token"><span class="punctuation token">=</span><span class="punctuation token">"</span>50<span class="punctuation token">"</span></span> <span class="attr-name token">cy</span><span class="attr-value token"><span class="punctuation token">=</span><span class="punctuation token">"</span>50<span class="punctuation token">"</span></span> <span class="attr-name token">r</span><span class="attr-value token"><span class="punctuation token">=</span><span class="punctuation token">"</span>30<span class="punctuation token">"</span></span><span class="language-css style-attr token"><span class="attr-name token"> <span class="attr-name token">style</span></span><span class="punctuation token">="</span><span class="attr-value token"><span class="property token">fill</span><span class="punctuation token">:</span><span class="hexcode token">#aaa</span></span><span class="punctuation token">"</span></span> <span class="attr-name token">id</span><span class="attr-value token"><span class="punctuation token">=</span><span class="punctuation token">"</span>circle<span class="punctuation token">"</span></span><span class="punctuation token">/&gt;</span></span>
  <span class="tag token"><span class="tag token"><span class="punctuation token">&lt;/</span><span class="namespace token">svg:</span>svg</span><span class="punctuation token">&gt;</span></span>
  <span class="tag token"><span class="tag token"><span class="punctuation token">&lt;</span>textarea</span> <span class="attr-name token">id</span><span class="attr-value token"><span class="punctuation token">=</span><span class="punctuation token">"</span>text<span class="punctuation token">"</span></span> <span class="attr-name token">rows</span><span class="attr-value token"><span class="punctuation token">=</span><span class="punctuation token">"</span>4<span class="punctuation token">"</span></span> <span class="attr-name token">cols</span><span class="attr-value token"><span class="punctuation token">=</span><span class="punctuation token">"</span>55<span class="punctuation token">"</span></span><span class="punctuation token">/&gt;</span></span>
<span class="tag token"><span class="tag token"><span class="punctuation token">&lt;/</span>body</span><span class="punctuation token">&gt;</span></span>
<span class="tag token"><span class="tag token"><span class="punctuation token">&lt;/</span>html</span><span class="punctuation token">&gt;</span></span></code></pre>

<h2 id="Notes" name="Notes"><a id="Notes" name="Notes"></a>Notes</h2>

<p>Le nom local d'un nœud est la partie de son nom qualifié qui suit les deux points. Les noms qualifiés sont typiquement utilisés en XML comme parties des espaces de noms de documents XML particuliers. Par exemple, dans le nom qualifié <code>ecomm:partners</code>, <code>partners</code> est le nom local et <code>ecomm</code> est le préfixe :</p>

<pre>&lt;ecomm:business id="soda_shop" type="brick_n_mortar"&gt;
  &lt;ecomm:partners&gt;
    &lt;ecomm:partner id="1001"&gt;Tony's Syrup Warehouse
    &lt;/ecomm:partner&gt;
  &lt;/ecomm:partner&gt;
&lt;/ecomm:business&gt;
</pre>

<p><span class="comment">Needs to be reworded; right now it's wrong. -Nickolay Le préfixe — dans ce cas « ecomm » — définit l'espace de noms dans lequel le nom local peut être utilisé.</span></p>

<div class="note">
<p>Dans {{Gecko("1.9.2")}} et antérieurs, la propriété retourne en casse majuscule le nom local pour les éléments HTML dans le DOM HTML (par opposition aux éléments XHTML dans le DOM XML). Dans les versions ultérieures, en conformité avec HTML5, la propriété renvoie dans le cas d'un stockage DOM interne, en casse minuscule pour les éléments HTML dans le DOM HTML et les éléments XHTML dans le DOM XML. La propriété  {{domxref("element.tagName","tagName")}} continue de renvoyer en casse majuscule pour les éléments HTML dans le DOM HTML.</p>
</div>

<p>Pour les nœuds de tout autre <a href="https://developer.mozilla.org/fr/docs/Web/API/Node/nodeType">type</a> qu'<code>ELEMENT_NODE</code> et <code>ATTRIBUTE_NODE</code>, <code>localName</code> vaut toujours <code>null</code>.</p>

<h2 id="Spécifications">Spécifications</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Spécification</th>
   <th scope="col">Statut</th>
   <th scope="col">Commentaire</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName('DOM3 Core', 'core.html#ID-NodeNSLocalN', 'Node.localName')}}</td>
   <td>{{Spec2('DOM3 Core')}}</td>
   <td> </td>
  </tr>
  <tr>
   <td>{{SpecName('DOM2 Core', 'core.html#ID-NodeNSLocalN', 'Node.localName')}}</td>
   <td>{{Spec2('DOM2 Core')}}</td>
   <td>Définition initiale</td>
  </tr>
 </tbody>
</table>

<h2 id="Compatibilité_des_navigateurs">Compatibilité des navigateurs</h2>



<p>{{Compat("api.Node.localName")}}</p>

<h3 id="Voir_aussi" name="Voir_aussi">Voir aussi</h3>

<ul>
 <li>{{domxref("Node.namespaceURI")}}</li>
 <li>{{domxref("Node.prefix")}}</li>
 <li>{{domxref("Element.localName")}}</li>
 <li>{{domxref("Attr.localName")}}</li>
</ul>

<p> </p>