代码
<html> <head> <title>javascript</title> <script language="javascript"> function showtime() { var now_time = new Date(); var hours = now_time.getHours(); var minutes = now_time.getMinutes(); var seconds = now_time.getSeconds(); var timer = "" + ((hours > 12) ? hours -12 : hours); timer += ((minutes < 10) ? ":0" : ":") + minutes; timer += ((seconds < 10) ? ":0" : ":") + seconds; timer +=" " + ((hours > 12) ? "pm" : "am"); document.clock.show.value = timer; setTimeout("showtime()",1000); } </script> </head> <body > <form name="clock" onSubmit="0"> <input type="text" name="show" size="10" style="background-color:lightyellow;border-width:3;"> </form> <script type="text/javascript"> document.write("<h1>hello world!</h1>") </script> </body> </html>
效果图预览
END !
时间: 2024-10-29 00:42:54