Ver Mensaje Individual
  #2 (permalink)  
Antiguo 19/09/2011, 06:05
de-troit
Invitado
 
Mensajes: n/a
Puntos:
Respuesta: Cambiar hash sin dejar historia

Se me ocurrió esta forma, lo pongo por si acaso a alguien mas le sirve:

Código Javascript:
Ver original
  1. //Extendemos objeto location con una función para poner un hash:
  2. window.location.setHash = function( hash ) {
  3.    hash = ( typeof hash !== 'undefined' ) ? '#' + hash : '#';
  4.  
  5.    if( window.location.hash.indexOf('#') !== -1 ) window.location.replace(
  6.         window.location.href.replace( /#.*/, hash )
  7.    );
  8.  
  9.    else window.location.replace( window.location.href + hash );
  10. }
  11.  
  12. //Ponemos un hash y al cabo de 2 segundos se cambia:
  13. window.location.setHash( 'hash' );
  14. setTimeout( function() { window.location.setHash( 'nuevoHash' ) }, 2000 );

Y ya no hay historia! se cambia de forma silenciosa :D

Última edición por de-troit; 19/09/2011 a las 16:42