VBScript to do a timer, encountered a problem, how the page on the continuous call of a VB function it ....
For example, Countdown, how to let the number of seconds in the case of not refreshing to walk ...
Thought for a long time, checked a lot of places are done with JavaScript ...
I finally found one, which is not in the help of VBScript. SetTimeout Property ... I'm so dizzy.
The countdown is as follows.
<textarea id="runcode83904"><! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" > <ptml> &L t;head> <meta http-equiv= "Content-type" content= "text/html"; charset=gb2312 "> <title> countdown </title> </pead> <body> <input type=" text "name=" Usetime "si Ze= "8" > <script language= "VBScript" > sec=2 min=1 hou=0 "settimeout sparetime ()", 1000 sub Sparetime () if Sec=0 and Min=0 and hou=0 then usetime.value= "time ends ~" Else sec=sec-1 if Sec=-1 then sec=59 min=min-1 End If If Min=-1 then min=59 hou=hou-1 End If If Len (HOU) <2 then hou= "0" &hou End If If Len (min) <2 then min= "0" &min End If If Len (sec) <2 then sec= "0" &sec ElseIf len (sec) <1 then sec=00 End If Usetime.val ue=hou& ":" &min& ":" &sec settimeout "Sparetime ()", 1000 End If End Sub </script> </body> </ptml></textarea>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
You can set up Sec/min/hou before running.
Here's another JavaScript. Current time:)
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" > <ptml> &L t;head> <meta http-equiv= "Content-type" content= "text/html"; charset=gb2312 "> <title>javascript current time </title> </pead> <body> <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)? PM ":" Morning ") TimeValue + = ((Hours >12)? hours-12:hours) TimeValue + = (Minutes < 10)? ": 0": ":" + minutes TimeValue + + (seconds <)? ": 0": ":") + seconds Document.clock.thetime.value = TimeValue; Timerid = settimeout ("Showtime ()", 1000); Timerrunning = true;} </script> <body onload=startclock () > <form name=clock > <input name=thetime size=12> </form> </bo Dy> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]