Ver Mensaje Individual
  #3 (permalink)  
Antiguo 17/04/2010, 06:56
Avatar de _cronos
_cronos
 
Fecha de Ingreso: abril-2010
Mensajes: 135
Antigüedad: 14 años, 1 mes
Puntos: 1
Respuesta: Problema con setInterval()

Bueno ahora supongo que tu código era el correcto pero tampoco lo puedo saber porque tengo esto:

Código HTML:
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. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  4. </head>
  5. <div id="capaNombre"></div>
  6. <div id="capaReloj"></div>
  7. </body>
  8. </html>

Código Javascript:
Ver original
  1. <script language="javascript" type="text/javascript">
  2. function reloj(){
  3. var nombre = prompt("Introduce tu nombre, por favor", "");
  4. var f = new Date();
  5. var a = f.getFullYear();
  6. var m = new Array ("Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre");
  7. var d = new Array ("Domingo","Lunes","Martes","Miércoles","Jueves","Viernes","Sábado");;
  8. var h = f.getHours();
  9. var mi = f.getMinutes();
  10. var s = f.getSeconds();
  11. if (h<10){h='0'+h}
  12. if (mi<10){mi='0'+mi}
  13. if (s<10){s='0'+s}
  14. document.getElementById("capaNombre").innerHTML= ('<div style=font-size:25px;>' + 'Hola,' + '<div style=font-size:30px;>' + nombre.charAt(0).toUpperCase() + nombre.substring(1,99) + '</div>');
  15. document.getElementById("capaReloj").innerHTML= ('Hoy es ' + d[f.getDay()] + ', ' + f.getDate() + ' de ' + m[f.getMonth()] + ' de ' + a + ' y son las ' + h + ':' + mi + ':' + s + '</div>');
  16. }
  17. setInterval("reloj()", 1000);
  18. </script>

para que también introduzca un nombre, pero ahora en vez de salir una sola vez, metes el nombre y si que lo escribe y muestra la hora pero siguen apareciendo más prompts una y otra vez y no sé porque es. Gracias (: