VB countdown Timer and JS Current time _ Basic knowledge

Source: Internet
Author: User
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]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.