Ver Mensaje Individual
  #11 (permalink)  
Antiguo 25/12/2011, 20:20
Avatar de truman_truman
truman_truman
 
Fecha de Ingreso: febrero-2010
Ubicación: /home/user
Mensajes: 1.341
Antigüedad: 14 años, 2 meses
Puntos: 177
Respuesta: ingresar datos en la URL

Pruebalo así:



Código Javascript:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4.   <title>PushState</title>
  5.     <script language="javascript" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script><!-- Actualizar -->
  6.     <script>
  7.     $(document).ready(function() {
  8.         // Para navegadores que soportan la función.
  9.         if (typeof window.history.pushState == 'function') {
  10.             pushstate();            
  11.         }else{
  12.             check(); hash();
  13.         }
  14.     });
  15.     // Chequear si existe el hash.
  16.     function check(){
  17.         var direccion = ""+window.location+"";
  18.         var nombre = direccion.split("#!");
  19.         if(nombre.length > 1){
  20.             var url = nombre[1];
  21.             alert(url);
  22.         }
  23.     }
  24.    
  25.     function pushstate(){
  26.         var links = $(".btn");
  27.         // Evento al hacer click.
  28.         links.live('click', function(event) {
  29.             var url = $(this).attr('value');
  30.             // Cambio el historial del navegador.
  31.             history.pushState({ path: url }, url, url);
  32.             // Muestro la nueva url
  33.             alert(url);
  34.             return false;
  35.         });
  36.        
  37.         // Función para determinar cuando cambia la url de la página.
  38.         $(window).bind('popstate', function(event) {
  39.             var state = event.originalEvent.state;
  40.             if (state) {
  41.                 // Mostrar url.
  42.                 alert(state.path);
  43.             }
  44.         });
  45.     }
  46.    
  47.     function hash(){
  48.         // Para i.e
  49.         // Función para determinar cuando cambia el hash de la página.
  50.         $(window).bind("hashchange",function(){
  51.             var hash = ""+window.location.hash+"";
  52.             hash = hash.replace("#!","")
  53.             if(hash && hash != ""){
  54.                 alert(hash);
  55.             }
  56.         });
  57.         // Evento al hacer click.
  58.         $(".btn").bind('click', function(e) {
  59.             e.preventDefault();
  60.             var url = $(this).attr('value');
  61.             // Cambio el historial del navegador.
  62.             window.location.hash = "#!"+url;
  63.             //$(window).trigger("hashchange");
  64.             return false
  65.         });
  66.     }
  67.     </script>  
  68.   </head>
  69.   <body>
  70.     <button type="button" id="btn" class="btn" value="page-help.html">Boton</button>
  71.         <button type="button" id="btn2" class="btn" value="other.html">Boton2</button>
  72.    
  73.   </body>
  74. </html>
__________________
la la la