Ver Mensaje Individual
  #10 (permalink)  
Antiguo 25/12/2011, 19:33
edward18_1
 
Fecha de Ingreso: septiembre-2011
Mensajes: 480
Antigüedad: 12 años, 7 meses
Puntos: 18
Respuesta: ingresar datos en la URL

noo ps es que la cosa es q no utilizo <a></a> si no <input> type button...entonces yo diria ps...que con jquery hacer lo de la URL...o sea q cuando precione el boton...rescato el id del boton..que eso se hacerlo ya...y ps...colocar el id en un # de la url sin recargar la pagina..eso es todo.... he estado viendo y segun se puede hacer con esto...pero solo funciona con <a></a>

q hay q hacerle para q funcione con los input type button?


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 = $("a");
  27.         // Evento al hacer click.
  28.         links.live('click', function(event) {
  29.             var url = $(this).attr('href');
  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.         $("a").bind('click', function(e) {
  59.             e.preventDefault();
  60.             var url = $(this).attr('href');
  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.     <a href="page-help.html">help</a>
  71.     <a href="other.html"> Otro link</a>
  72.   </body>
  73. </html>