ccc

Obtener Hash de la url

if ("onhashchange" in window) { // navegadores que detectan el cambio de hash
        window.onhashchange = function () {
          cambioContenido(window.location.hash);
        }
      } else { // navegadores que no lo detectan
        var hash_previo = window.location.hash;
        window.setInterval(function () {
          if (window.location.hash != hash_previo) {
            hash_previo = window.location.hash;
            cambioContenido(hash_previo);
          }
        }, 100);
      }


function cambioContenido(hash) {
        switch (hash){
          case '#lo-que-sea':
              ...
              break;
        }
      }

Ej: www.midominio.com/#lo-que-sea

No hay comentarios:

Publicar un comentario