aboutsummaryrefslogtreecommitdiff
path: root/files/es/web/api/element/localname/index.html
blob: 0876729853e0b860c69d4a3da419fb4bf602a81c (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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
---
title: Element.localName
slug: Web/API/Element/localName
tags:
  - API
  - Compatibilidad de los Navegadores en Móviles
  - Compatibilidad de los navegadores
  - DOM
  - Propiedad
  - Referencia
translation_of: Web/API/Element/localName
---
<div>{{APIRef("DOM")}}</div>

<p>La propiedad únicamente de lectura <code><strong>Element.localName</strong></code> devuelve la parte local del nombre calificado de un objeto.</p>

<div class="note">
<p>Antes de DOM4 esta API fué definida dentro de la interfaz{{domxref("Node")}}.</p>
</div>

<h2 id="Sintasix">Sintasix</h2>

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

<h3 id="Valor_de_Retorno">Valor de Retorno</h3>

<p> {{domxref("DOMString")}} <span id="result_box" lang="es"><span>que representa la parte</span> <span>local del</span> <span>nombre cualificado</span> <span>del elemento.</span></span></p>

<h2 id="Ejemplo">Ejemplo</h2>

<p>(debe ser servido con contenido tipo XML , como <code>text/xml</code> o <code>application/xhtml+xml</code>.)</p>

<pre class="brush:xml">&lt;html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:svg="http://www.w3.org/2000/svg"&gt;
&lt;head&gt;
  &lt;script type="application/javascript"&gt;&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;&lt;/script&gt;
&lt;/head&gt;
&lt;body onload="test()"&gt;
  &lt;svg:svg version="1.1"
    width="100px" height="100px"
    viewBox="0 0 100 100"&gt;
    &lt;svg:circle cx="50" cy="50" r="30" style="fill:#aaa" id="circle"/&gt;
  &lt;/svg:svg&gt;
  &lt;textarea id="text" rows="4" cols="55"/&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>

<h2 id="Notas">Notas</h2>

<p><span id="result_box" lang="es"><span>El nombre local</span> <span>de un nodo</span> <span>es la parte del</span> <span>nombre completo</span> <span>del</span> <span>nodo que</span> <span>va situado después de</span> <span>los dos puntos.</span> <span>Nombres calificados</span> <span>se utilizan normalmente en</span> <span>XML</span> <span>como parte</span> <span>del espacio de los nombres</span> <span>(s)</span> <span>de los</span> <span>documentos particulares XML</span> <span>.</span> <span>Por ejemplo</span><span>,</span> <span>en el nombre</span> calificado <span>ecomm</span> <span>:</span> <span>socios</span><span>,</span>  <span>socios</span> <span>es el nombre</span> <span>local y</span> <span>ecomm</span> <span>es</span> <span>el prefijo</span><span>:</span></span></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">1  &lt;</span><span class="namespace token">ecomm:</span>business</span> <span class="attr-name token">id</span><span class="attr-value token"><span class="punctuation token">=</span><span class="punctuation token">"</span>soda_shop<span class="punctuation token">"</span></span> <span class="attr-name token">type</span><span class="attr-value token"><span class="punctuation token">=</span><span class="punctuation token">"</span>brick_n_mortar<span class="punctuation token">"</span></span> <span class="attr-name token"><span class="namespace token">xmlns:</span>ecomm</span><span class="attr-value token"><span class="punctuation token">=</span><span class="punctuation token">"</span>http://example.com/ecomm<span class="punctuation token">"</span></span><span class="punctuation token">&gt;</span></span>
2   <span class="tag token"><span class="tag token"><span class="punctuation token">&lt;</span><span class="namespace token">ecomm:</span>partners</span><span class="punctuation token">&gt;</span></span>
3    <span class="tag token"><span class="tag token"><span class="punctuation token">&lt;</span><span class="namespace token">ecomm:</span>partner</span> <span class="attr-name token">id</span><span class="attr-value token"><span class="punctuation token">=</span><span class="punctuation token">"</span>1001<span class="punctuation token">"</span></span><span class="punctuation token">&gt;</span></span>Tony's Syrup Warehouse
4     <span class="tag token"><span class="tag token"><span class="punctuation token">&lt;/</span><span class="namespace token">ecomm:</span>partner</span><span class="punctuation token">&gt;</span></span>
5    <span class="tag token"><span class="tag token"><span class="punctuation token">&lt;/</span><span class="namespace token">ecomm:</span>partner</span><span class="punctuation token">&gt;</span></span>
<span class="tag token"><span class="tag token"><span class="punctuation token">6  &lt;/</span><span class="namespace token">ecomm:</span>business</span><span class="punctuation token">&gt;</span></span></code></pre>

<div class="note">
<p><strong>Nota:</strong> En {{Gecko("1.9.2")}} y anteriores,devuelve la versión en mayúsculas del nombre local para elementos HTML en HTML DOMs (en contraposición a elementos XHTML en XML DOMs). En versiones posteriores, en concordancia con HTML5,<span id="result_box" lang="es"><span>la propiedad devuelve</span> <span>en</span> <span>el caso de</span> <span>almacenamiento</span> <span>interno DOM</span></span><span id="result_box" lang="es"> <span>minúscula</span> <span>para ambos elementos</span> <span>HTML en</span> <span>HTML</span> <span>DOM</span> <span>y</span> <span>elementos XHTML</span> <span>en</span> <span>DOM</span> <span>XML</span></span>. La propiedad {{domxref("element.tagName","tagName")}} continua devolviéndolo en mayúsculas para elementos HTML en HTML DOMs.</p>
</div>

<h2 id="Especificaciones">Especificaciones</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Especificación</th>
   <th scope="col">Estado</th>
   <th scope="col">Comentario</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName('DOM4', '#interface-element', 'Element.localName')}}</td>
   <td>{{Spec2('DOM4')}}</td>
   <td>definición inicial</td>
  </tr>
 </tbody>
</table>

<h2 id="Compatibilidad_de_los_navegadores">Compatibilidad de los navegadores</h2>

<p>{{CompatibilityTable}}</p>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Función</th>
   <th>Chrome</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari</th>
  </tr>
  <tr>
   <td>Soporte Básico</td>
   <td>46.0<sup>[1]</sup></td>
   <td>{{CompatGeckoDesktop("48.0")}}<sup>[1]</sup></td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Función</th>
   <th>Android</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>IE Mobile</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td>Soporte Básico</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatGeckoMobile("48.0")}}<sup>[1]</sup></td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
 </tbody>
</table>
</div>

<p>[1] Esta API estaba disponible previamente en la  {{domxref("Node")}} API.</p>

<h2 id="Ver_también">Ver también</h2>

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