31
Me pregunto si es posible cambiar el hash en window.location.hash y reemplazarlo por 'this.id'. ¿O necesitaría cambiar la window.location completa?posible reemplazar window.location.hash?
Me pregunto si es posible cambiar el hash en window.location.hash y reemplazarlo por 'this.id'. ¿O necesitaría cambiar la window.location completa?posible reemplazar window.location.hash?
Sí, puedes. Hago algo similar en uno de mis sitios, aunque con href
en lugar de id
, pero id
también funciona. Un ejemplo rápido:
$('a[id]').click(function(e)
{
// This will change the URL fragment. The change is reflected
// on your browser's address bar as well
window.location.hash = this.id;
e.preventDefault();
});
Maravilloso :-) ¡Muchas gracias! – circey
¿Es este navegador cruzado? – jldupont
@jldupont: Creo que sí. – BoltClock