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>