<html>
<head>
<title>Reloj con Javascript</title>
<script language=”JavaScript”>
function reloj(){
ahora = new Date()
hora = ahora.getHours()
minuto = ahora.getMinutes()
segundo = ahora.getSeconds()
<!–Si los digitos del segundo son 1, entonces se concatena un “0″–>
str_segundo = new String (segundo)
if (str_segundo.length == 1)
segundo = “0″ + segundo
<!–Si los digitos del minuto son 1, entonces se concatena un “0″–>
str_minuto = new String (minuto)
if (str_minuto.length == 1)
minuto = “0″ + minuto
<!–Si los digitos de la hora son 1, entonces se concatena un “0″–>
str_hora = new String (hora)
if (str_hora.length == 1)
hora = “0″ + hora
mostrarHora = hora + ” : ” + minuto + ” : ” + segundo
document.form_reloj.reloj.value = mostrarHora
setTimeout(“reloj()”,1000)
}
</script>
</head>
<body onload=”reloj()”>
<form name=”form_reloj”>
<input type=”text” name=”reloj” onfocus=”window.document.form_reloj.reloj.blur()”>
</form>
</body>
</html>






