JS implementation countdown (distance end also) sample code

Source: Internet
Author: User
This article with you to share a JS implementation of the countdown code, the main function distance to the end of how much time, interested friends can refer to the hope that you learn JS has helped copy code code as follows:


<script language= "JavaScript" >
<!--
var maxtime = 60*60;//60*60//One hours, in seconds, adjust yourself!
Function Countdown () {
if (maxtime>=0) {
//minutes = Math.floor (MAXTIME/60);
seconds = Math.floor (maxtime%60);
//msg = "End of distance also has" +minutes+ "minute" +seconds+ "seconds";
msg = "End of distance and" +seconds+ "seconds";
document.all["Timer"].INNERHTML=MSG;
if (maxtime = = 5*60) {
Alert (' Note, 5 minutes! ');
}
--maxtime;
}else{
Clearinterval (timer);
//alert ("Time to, end!");
Maxtime=60*60;
Timer = setinterval ("Countdown ()", 1000);
}
}
Timer = SetInterval ("Countdown ()", 1000);
//-->
</SCRIPT>
<div id= "Timer" style= "color:red" ></div>
<script language= " JavaScript ">
<!--
var maxtime = 5*60;//60*60//One hours, per second, adjust yourself!
Var timer;
Function Countdown () {
if (maxtime>=0) {
var minutes = Math.floor (MAXTIME/60);
var seconds = Math.floor (maxtime%60);
var msg = "Distance Refresh and"+minutes+ "Minutes" +seconds+ "seconds";
$ (' #timer '). HTML (msg);
//document.all["Timer"].INNERHTML=MSG;
--maxtime;
}else{
Clearinterval (timer);
//Two methods are the methods that are called after the countdown is over
Searchtasklist ();
Myajax ();
//Set the next Countdown
Maxtime=5*60;
Timer = setinterval ("Countdown ()", 1000);
}
}
Timer = SetInterval ("Countdown ()", 1000);
//-->
</SCRIPT>
<div id= "Timer" style= "display:inline;color:red" ></DIV>

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.