1. Add the following code to Copy codeThe Code is as follows:
<Script language = JavaScript>
Var timerID = null;
Var timerRunning = false;
Function stopclock (){
If (timerRunning)
ClearTimeout (timerID );
TimerRunning = false ;}
Function startclock (){
Stopclock ();
Showtime ();}
Function showtime (){
Var now = new Date ();
Var hours = now. getHours ();
Var minutes = now. getMinutes ();
Var seconds = now. getSeconds ()
Var timeValue = "" + (hours> = 12 )? "Afternoon": "Morning ")
TimeValue + = (hours> 12 )? Hours-12: hours)
TimeValue + = (minutes <10 )? ": 0": ":") + minutes
TimeValue + = (seconds <10 )? ": 0": ":") + seconds
Document. clock. thetime. value = timeValue;
TimerID = setTimeout ("showtime ()", 1000 );
TimerRunning = true ;}
</SCRIPT>
2. Add the following code to <body>:
Onload = startclock ()
3. Insert the following code at the display time. We recommend that you use table positioning.
[Code]
<Form name = clock>
<Input name = thetime style = "font-size: 9pt; color: #000000; border: 0" size = 12>
</Form>
// Only obtain the function of the current system date
<Script language = "JavaScript" type = "text/javascript">
Document. write (new Date (). getYear () + "-" + (new Date (). getMonth () + 1) + "-" + new Date (). getDate ());
</Script>
Http://www.jb51.net/article/12786.htm