JS timer (timer) and clock

Source: Internet
Author: User

Record it to prevent future use, collect from the network, and be compatible with IE and Firefox.

JS timer (timer)
Bytes -------------------------------------------------------------------------------------------------

<HTML> <br/> <pead> <br/> <title> nonove JS timer </title> <br/> </pead> <br/> <body> <br/> <MCE: script Language = "JavaScript"> <! -- <Br/> var se, m = 0, H = 0, S = 0, Ss = 1; <br/> function second () {<br/> If (SS % 100) = 0) {S + = 1; SS = 1 ;} <br/> If (S> 0 & (S % 60) = 0) {M + = 1; S = 0 ;} <br/> If (M> 0 & (M % 60) = 0) {H + = 1; M = 0 ;} <br/> T = H + "Hour" + M + "Minute" + S + "second" + SS + "millisecond"; <br/> document. getelementbyid ("Showtime "). value = T; <br/> SS + = 1; <br/>}< br/> function startclock () {Se = setinterval ("second ()", 1) ;}< br/> function pauseclock () {clearinterval (SE) ;}< br/> function stopclock () {clearinterval (SE); SS = 1; M = H = s = 0 ;}< br/> // --> </MCE: SCRIPT> <br/> <input name = "S" type = "button" value = "start timing" onclick = "startclock () "> <br/> <input name =" S "type =" button "value =" Pause timing "onclick =" pauseclock () "> <br/> <input name =" S "type =" button "value =" Stop timing "onclick =" stopclock () "> </P> <p> <input name =" Showtime "style =" color: # ff0000; width: 200px; "id =" Showtime "type =" text "value =" 00:00:00 "> <br/> </body> <br/> </ptml>

Bytes -------------------------------------------------------------------------------------------------

Javascript clock (clock) is compatible with IE and Firefox
Bytes -------------------------------------------------------------------------------------------------

 

<HTML> <br/> <pead> <br/> <title> nonove JS Clock </title> <br/> <MCE: script Type = "text/JavaScript"> <! -- <Br/> function clock () {<br/> var date = new date (); <br/> This. year = date. getfullyear (); <br/> This. month = date. getmonth () + 1; <br/> This. date = date. getdate (); <br/> This. day = new array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday") [date. getday ()]; <br/> This. hour = date. gethours () <10? "0" + date. gethours (): Date. gethours (); <br/> This. Minute = date. getminutes () <10? "0" + date. getminutes (): Date. getminutes (); <br/> This. Second = date. getseconds () <10? "0" + date. getseconds (): Date. getseconds (); <br/> This. tostring = function () {<br/> return "now:" + this. year + "year" + this. month + "month" + this. date + "day" + this. hour + ":" + this. minute + ":" + this. second + "" + this. day; <br/>}; <br/> This. tosimpledate = function () {<br/> return this. year + "-" + this. month + "-" + this. date; <br/>}; <br/> This. todetaildate = function () {<br/> return this. year + "-" + This. month + "-" + this. date + "" + this. hour + ":" + this. minute + ":" + this. second; <br/>}; <br/> This. display = function (Ele) {<br/> var clock = new clock (); <br/> ELE. innerhtml = clock. tostring (); <br/> window. setTimeout (function () {clock. display (Ele) ;}, 1000); <br/>}; <br/>}< br/> // --> </MCE: SCRIPT> <br/> </pead> <br/> <body> <br/> <Div id = "Clock" align = "center"> </div> <br /> <MCE: script Type = "Text/JavaScript"> <! -- <Br/> var clock = new clock (); <br/> clock. display (document. getelementbyid ("Clock"); <br/> // --> </MCE: SCRIPT> <br/> </body> <br/> </ptml>

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.