Ver Mensaje Individual
  #1 (permalink)  
Antiguo 12/12/2010, 22:36
Alexis37
 
Fecha de Ingreso: diciembre-2010
Mensajes: 17
Antigüedad: 13 años, 5 meses
Puntos: 0
¿Cómo puedo lograr esto con cookies?

Ya tengo la página de usuario y la de login, pero sucede que al entrar el usuario, no hace los cambios guardados desde la última vez que entró a dicha página (como la fuente y la imagen de fondo).

Aquí les muestro lo que tengo hecho, no encuentro cómo hacerle. Gracias de antemano. Saludos.

Código Javascript:
Ver original
  1. <html>
  2. <head>
  3. <script language="javascript">
  4.     function login()
  5.     {
  6.     dom_us=document.getElementById('usuario');
  7.     dom_password=document.getElementById('contraseña');
  8.     document.cookie=dom_us.value+'='+dom_password.value;
  9.     document.cookie="usuario_activo"+"="+dom_us.value;
  10.     alert(document.cookie);
  11.    
  12.     window.location="select_func_cookies.html";
  13.    
  14.     }
  15. </script>
  16. </head>
  17.  
  18. <body bgcolor="#3399CC">
  19.  
  20. <form name="formulario" action="">
  21. <label for="usuario">Usuario</label>
  22. <input type="text" id="usuario">
  23. <br><br>
  24. <label for="contraseña">Contraseña</label>
  25. <input type="password" id="contraseña">
  26. <input type="button" name="boton" value="Entrar" onclick="login()">
  27. </form>
  28.  
  29. </body>
  30. </html>

La otra página:
Código Javascript:
Ver original
  1. <html>
  2. <head>
  3. <script language="javascript">
  4.  
  5.     function cambiar()
  6.     {
  7.     dom_select=document.getElementsByTagName('select')[1];
  8.         if(dom_select.selectedIndex==0)
  9.         {dom_img=document.getElementsByTagName('body')[0];
  10.         dom_img.setAttribute('background','Sasuke.jpg');
  11.         valor_cookie="Sasuke.jpg";}
  12.         if(dom_select.selectedIndex==1)
  13.         {dom_img=document.getElementsByTagName('body')[0];
  14.         dom_img.setAttribute('background','Neji.jpg');
  15.         valor_cookie="Neji.jpg";}
  16.  
  17.     dom_select2=document.getElementsByTagName('select')[0];
  18.         if(dom_select2.selectedIndex==0)
  19.         {dom_f=document.getElementsByTagName('font')[0];
  20.         dom_f.setAttribute('face','Arial');
  21.         valor_cookie=valor_cookie+'/Arial';}
  22.        
  23.         if(dom_select2.selectedIndex==1)
  24.         {dom_f=document.getElementsByTagName('font')[0];
  25.         dom_f.setAttribute('face','Book Antiqua');
  26.         valor_cookie=valor_cookie+'/Book Antiqua';}
  27.    
  28.         if(dom_select2.selectedIndex==2)
  29.         {dom_f=document.getElementsByTagName('font')[0];
  30.         dom_f.setAttribute('face','Century Gothic');
  31.         valor_cookie=valor_cookie+'/Century Gothic';}
  32.    
  33.     document.cookie='cookie1'+'='+valor_cookie;//valor_cookie+Arial, ejemplo de cómo guardarla con más valores
  34.     alert(document.cookie);
  35.  
  36.     }
  37.  
  38. function after_login()
  39. {
  40. cookies_almacenadas=document.cookie.split(";");
  41.  
  42. for(var x=0;x<cookies_almacenadas.length;x++)
  43.  {
  44.    cookie_buscada=cookies_almacenadas[x].split("=");
  45.      if(cookie_buscada[0]=='usuario_activo')
  46.      {}
  47.  }
  48. }
  49. </script>
  50. </head>
  51.  
  52. <body bgcolor="black">
  53.  
  54. <select name="lista_f">
  55. <option value="Arial">Arial</option>
  56. <option value="Book Antiqua">Book Antiqua</option>
  57. <option value="Century Gothic">Century Gothic</option>
  58. </select>
  59.  
  60. <select name="lista_img">
  61. <option value="Sasuke">Sasuke</option>
  62. <option value="Neji">Neji</option>
  63.  
  64. </select>
  65. <input type="button" name="boton" value="Cambiar" onclick="cambiar()">
  66. <br>
  67. <p align="center">
  68. <font size=4 color="white">Yatzil Reyes Morales. ISC - 301. Programación II. Universidad Jean Piaget.</font>
  69. </p>
  70. </body>
  71. </html>