Código Javascript:
Ver original
<html> <head> <title>Reloj con Javascript</title> <script language="JavaScript"> function mueveReloj(){ momentoActual = new Date() hora = momentoActual.getHours() minuto = momentoActual.getMinutes() segundo = momentoActual.getSeconds() horaImprimible = hora + " : " + minuto + " : " + segundo document.form_reloj.reloj.value = horaImprimible setTimeout("mueveReloj()",1000) } </script> </head> <body onload="mueveReloj()"> Vemos aquí el reloj funcionando... <form name="form_reloj"> <input type="text" name="reloj" size="10"> </form> </body> </html>
Código HTML:
Ver original
<!DOCTYPE html> <html> <head> <script> function HoraAjax() { var xmlhttp; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("myDiv").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","ObtenerHora.php",true); xmlhttp.send(); } </script> </head> <body> </body> </html>
ObtenerHora
Código PHP:
Ver original
<?php ?>