页面时钟
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <style type="text/css"> input {width:2em}; </style> <body> <input id="year"/>年 <input id="month"/>月 <input id="date"/>日 <input id="hour"/>时 <input id="minute"/>分 <input id="second"/>秒 </body> </html> <script type="text/javascript"> function clockChange(){ var date=new Date(); var d=document; d.getElementById("year").value=date.getFullYear(); d.getElementById("month").value=date.getMonth()+1; d.getElementById("date").value=date.getDay(); d.getElementById("hour").value=date.getHours(); d.getElementById("minute").value=date.getMinutes(); d.getElementById("second").value=date.getSeconds(); setTimeout("clockChange()",1000); } clockChange(); </script>