JavaScript-Stop Timer

Source: Internet
Author: User
Tags date1

Stop Timer
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" ><html>  <head>    <title>Stop Timer</title>    <script type="Text/javascript">        //page loading complete after executionWindow.onload= function(){            vartoday=New Date();//var date1=new Date ("2014/02/14 12:30:00");            //alert (date1);            varYear=today.getfullyear ();varMonth=today.getmonth () +1;varDate=today.getdate ();varHour=today.gethours (); Hour=checktime (hour);varMinute=today.getminutes (); Minute=checktime (minute);varSecond=today.getseconds (); Second=checktime (second);varcurrenttime=year+"Year"+month+"Month"+date+"Day"+hour+":"+minute+":"+second; document.getElementById ("Time"). Innerhtml=currenttime;//print ();}//Check time, for single digit complement 0         function checktime(t){            if(t<Ten) {t="0"+t; }returnT }//Timer settimeout ()        varTimer function print(){            varObjp=document.getelementbyid ("Itany"); objp.innerhtml+="Hello world!<br/>"; Timer=settimeout ("Print ()", -); }//Stop timer         function stoptimer(){Cleartimeout (timer); }//Timer setinterval ()         function print2(){            varObjp=document.getelementbyid ("Itany"); objp.innerhtml+="Hello world!<br/>"; }varTimer2; function startTimer2(){Timer2=setinterval ("Print2 ()", +); } function stopTimer2(){Clearinterval (TIMER2); }</script>  </head>  <body>    <div id="Time">  </div>    <input type="button" value="Start Timer" onclick ="StartTimer2 ()" />&nbsp;<input type="button" value="Stop timer" onclick=" StopTimer2 () " />    <p id="Itany"></P>  </body></html>

JavaScript-Stop Timer

Related Article

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.