--- title: WindowEventHandlers.onhashchange slug: Web/API/WindowEventHandlers/onhashchange tags: - HTML-DOM - JavaScript - Propiedades - Referencia - WindowEventHandlers - eventos translation_of: Web/API/WindowEventHandlers/onhashchange ---
El evento hashchange se dispara cuando la almohadilla ha cambiado (ver {{domxref("Window.location", "location.hash")}}).
window.onhashchange = funcRef;
ó
<body onhashchange="funcRef();">
ó
window.addEventListener("hashchange", funcRef, false);
funcRef
if ("onhashchange" in window) { alert("¡El navegador soporta el evento hashchange!"); } function locationHashChanged() { if (location.hash === "#somecoolfeature") { somecoolfeature(); } } window.onhashchange = locationHashChanged;
El evento hashchange
enviado, tiene los siguientes campos:
Campo | Tipo | Descripción |
newURL {{gecko_minversion_inline("6.0")}} |
DOMString |
La URL nueva hacia la cual la ventana está navegando. |
oldURL {{gecko_minversion_inline("6.0")}} |
DOMString |
La URL anterior desde la cual la ventana navegó. |
Especificacion | Estado | Comentario |
---|---|---|
{{SpecName('HTML WHATWG', '#windoweventhandlers', 'GlobalEventHandlers')}} | {{Spec2('HTML WHATWG')}} | |
{{SpecName('HTML5.1', '#windoweventhandlers', 'GlobalEventHandlers')}} | {{Spec2('HTML5.1')}} | |
{{SpecName("HTML5 W3C", "#windoweventhandlers", "GlobalEventHandlers")}} | {{Spec2('HTML5 W3C')}} |
{{CompatibilityTable}}
Caracteristica | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Soporte Basico | 5.0 | {{CompatGeckoDesktop("1.9.2")}} |
8.0
|
10.6 | 5.0 |
Feature | Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Soporte Basico | 2.2 | {{CompatGeckoMobile("1.9.2")}} | 9.0 | 11.0 | 5.0 |