El evento hashchange se dispara cuando la almohadilla ha cambiado (ver location.hash
).
Sintaxis
window.onhashchange = funcRef;
贸
<body onhashchange="funcRef();">
贸
window.addEventListener("hashchange", funcRef, false);
Par谩metros
funcRef
- Una referencia a una funci贸n.
Ejemplo
if ("onhashchange" in window) {
alert("隆El navegador soporta el evento hashchange!");
}
function locationHashChanged() {
if (location.hash === "#somecoolfeature") {
somecoolfeature();
}
}
window.onhashchange = locationHashChanged;
El evento hashchange
El evento hashchange
enviado, tiene los siguientes campos:
Campo | Tipo | Descripci贸n |
newURL |
DOMString |
La URL nueva hacia la cual la ventana est谩 navegando. |
oldURL |
DOMString |
La URL anterior desde la cual la ventana naveg贸. |
Especificaciones
Especificacion | Estado | Comentario |
---|---|---|
HTML Living Standard La definici贸n de 'GlobalEventHandlers' en esta especificaci贸n. |
Living Standard | |
HTML 5.1 La definici贸n de 'GlobalEventHandlers' en esta especificaci贸n. |
Recommendation | |
HTML5 La definici贸n de 'GlobalEventHandlers' en esta especificaci贸n. |
Recommendation |
Compatibilidad en navegadores
We're converting our compatibility data into a machine-readable JSON format.
This compatibility table still uses the old format,
because we haven't yet converted the data it contains.
Find out how you can help!
Caracteristica | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Soporte Basico | 5.0 | 3.6 (1.9.2) |
8.0
|
10.6 | 5.0 |
Feature | Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Soporte Basico | 2.2 | 1.0 (1.9.2) | 9.0 | 11.0 | 5.0 |