diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:41:45 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:41:45 -0500 |
commit | 1109132f09d75da9a28b649c7677bb6ce07c40c0 (patch) | |
tree | 0dd8b084480983cf9f9680e8aedb92782a921b13 /files/es/web/api/window/hashchange_event/index.html | |
parent | 4b1a9203c547c019fc5398082ae19a3f3d4c3efe (diff) | |
download | translated-content-1109132f09d75da9a28b649c7677bb6ce07c40c0.tar.gz translated-content-1109132f09d75da9a28b649c7677bb6ce07c40c0.tar.bz2 translated-content-1109132f09d75da9a28b649c7677bb6ce07c40c0.zip |
initial commit
Diffstat (limited to 'files/es/web/api/window/hashchange_event/index.html')
-rw-r--r-- | files/es/web/api/window/hashchange_event/index.html | 194 |
1 files changed, 194 insertions, 0 deletions
diff --git a/files/es/web/api/window/hashchange_event/index.html b/files/es/web/api/window/hashchange_event/index.html new file mode 100644 index 0000000000..e0a5be4bbc --- /dev/null +++ b/files/es/web/api/window/hashchange_event/index.html @@ -0,0 +1,194 @@ +--- +title: hashchange +slug: Web/API/Window/hashchange_event +tags: + - Referencia + - URL + - Web +translation_of: Web/API/Window/hashchange_event +--- +<p>El evento <code>hashchange</code> es ejecutado cuando el fragmento identificador de la URL ha cambiado (la parte de la URL que continúa despues del simbolo #, incluyendo el símbolo #).</p> + +<table class="properties"> + <tbody> + <tr> + <td>Burbujas</td> + <td>Si</td> + </tr> + <tr> + <td>Cancelable</td> + <td>No</td> + </tr> + <tr> + <td>Objetivo</td> + <td>{{domxref("Window")}}</td> + </tr> + <tr> + <td>Interface</td> + <td>{{domxref("HashChangeEvent")}}</td> + </tr> + <tr> + <td>Acción predeterminada</td> + <td>Ninguna</td> + </tr> + </tbody> +</table> + +<h2 id="Propiedades">Propiedades</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">Property</th> + <th scope="col">Type</th> + <th scope="col">Description</th> + </tr> + </thead> + <tbody> + <tr> + <td><code>target</code> {{readonlyInline}}</td> + <td>{{domxref("EventTarget")}}</td> + <td>The browsing context (<code>window</code>).</td> + </tr> + <tr> + <td><code>type</code> {{readonlyInline}}</td> + <td>{{domxref("DOMString")}}</td> + <td>The type of event.</td> + </tr> + <tr> + <td><code>bubbles</code> {{readonlyInline}}</td> + <td>{{jsxref("Boolean")}}</td> + <td>Whether the event normally bubbles or not.</td> + </tr> + <tr> + <td><code>cancelable</code> {{readonlyInline}}</td> + <td>{{jsxref("Boolean")}}</td> + <td>Whether the event is cancellable or not.</td> + </tr> + <tr> + <td><code>oldURL</code> {{readonlyInline}}</td> + <td>{{jsxref("String")}}</td> + <td>The previous URL from which the window was navigated.</td> + </tr> + <tr> + <td>newURL {{readonlyInline}}</td> + <td>{{jsxref("String")}}</td> + <td> </td> + </tr> + </tbody> +</table> + +<p>En <a href="https://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-Browser-Polyfills">esta página</a> se enlistan algunos scripts de ejemplo. Básicamente estos scripts revisan el <code>location.hash</code> en un intervalo regular. Aquí se muestra una versión que permite que solo un controlador sea ligado a la propiedad <code>window.onhashchange</code>:</p> + +<pre class="brush:js;">;(function(window) { + + // salir si el navegador implementa el evento + if ("onhashchange" in window) { return; } + + var location = window.location, + oldURL = location.href, + oldHash = location.hash; + + // revisa el hash cada 100ms + setInterval(function() { + var newURL = location.href, + newHash = location.hash; + + // si el hash ha cambiado y un controlador ha sido ligado... + if (newHash != oldHash && typeof window.onhashchange === "function") { + // ejecuta el controlador + window.onhashchange({ + type: "hashchange", + oldURL: oldURL, + newURL: newURL + }); + + oldURL = newURL; + oldHash = newHash; + } + }, 100); + +})(window); +</pre> + +<h2 id="Especificaciones">Especificaciones</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">Especificacion</th> + <th scope="col">Estado</th> + <th scope="col">Comentario</th> + </tr> + <tr> + <td>{{SpecName('HTML WHATWG', 'indices.html#event-hashchange', 'hashchange')}}</td> + <td>{{Spec2('HTML WHATWG')}}</td> + <td>Definición inicial</td> + </tr> + </tbody> +</table> + +<h2 id="Compatibilidad_con_navegadores">Compatibilidad con navegadores</h2> + +<p>{{CompatibilityTable}}</p> + +<div id="compat-desktop"> +<table class="compat-table"> + <tbody> + <tr> + <th>Característica</th> + <th>Chrome</th> + <th>Edge</th> + <th>Firefox (Gecko)</th> + <th>Internet Explorer</th> + <th>Opera</th> + <th>Safari</th> + </tr> + <tr> + <td>Soporte Básico</td> + <td>5.0</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatGeckoDesktop("1.9.2")}}<sup>[1]</sup></td> + <td>8.0<sup>[2]</sup></td> + <td>10.6</td> + <td>5.0</td> + </tr> + </tbody> +</table> +</div> + +<div id="compat-mobile"> +<table class="compat-table"> + <tbody> + <tr> + <th>Característica</th> + <th>Android</th> + <th>Edge</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>2.2</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatGeckoMobile("1.9.2")}}</td> + <td>9.0</td> + <td>11.0</td> + <td>5.0</td> + </tr> + </tbody> +</table> +</div> + +<p>[1] Soporte para los atributos <code>oldURL</code>/<code>newURL</code> agregado en Firefox 6.</p> + +<p>[2] Atributos <code>oldURL</code>/<code>newURL</code> no soportados.</p> + +<h2 id="Ver_también">Ver también</h2> + +<ul> + <li><a href="/en-US/docs/Mozilla_event_reference/popstate"><code>popstate</code></a></li> + <li><a href="/en-US/docs/Web/API/WindowEventHandlers/onhashchange">WindowEventHandlers.onhashchange</a></li> +</ul> |