Tema: reloj simple
Ver Mensaje Individual
  #10 (permalink)  
Antiguo 31/10/2011, 09:46
Avatar de Panino5001
Panino5001
Me alejo de Omelas
 
Fecha de Ingreso: mayo-2004
Ubicación: -34.637167,-58.462984
Mensajes: 5.148
Antigüedad: 19 años, 10 meses
Puntos: 834
Respuesta: reloj simple

Mirá los comentarios
Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<
title>Untitled Document</title>
<
script type="text/javascript">
function 
ahora(){
     var 
nuevaFecha = new Date();
     var 
horas nuevaFecha.getHours();
     var 
minutos nuevaFecha.getMinutes();
     var 
segundos nuevaFecha.getSeconds();
     if (
horas <= 9horas "0" horas
     if (
minutos <= 9minutos "0" minutos
     if (
segundos <= 9segundos "0" segundos
     var 
tiempo horas " : " minutos " : " segundos;
     
texto document.createTextNode(tiempo);
     
document.getElementById("contenedor").replaceChild(texto,document.getElementById("contenedor").firstChild);
}
function 
ahora2(){
    var 
nuevaFecha = new Date();
    var 
horas nuevaFecha.getHours();
    var 
minutos nuevaFecha.getMinutes();
    var 
segundos nuevaFecha.getSeconds();
    if (
horas <= 9horas "0" horas
    if (
minutos <= 9minutos "0" minutos
    if (
segundos <= 9segundos "0" segundos
    var 
tiempo horas " : " minutos " : " segundos;
    
document.getElementById("contenedor2").innerHTML=tiempo;//ojo innerHTML es propiedad, no método
}
onload=function(){
    
setInterval(ahora1000);//mejor invocar que evaluar (no usar comillas ni paréntesis)
    
setInterval(ahora21000);
}
</script>
</head>

<body>
<div id="contenedor">...</div><!--ojo, tiene que haber un nodo de texto inicialmente -->
<div id="contenedor2"></div>
</body>
</html> 

Última edición por Panino5001; 31/10/2011 a las 09:53