Example 1
Countdown Refresh Page
| The code is as follows |
Copy Code |
| <script type= "Text/javascript" language= "JavaScript" >
var starttime = new Date (); var endtime=starttime.gettime () +10*60*1000; var g_blinkswitch = 0; var g_blinktitle = Document.title; function Getremaintime () {
var nowtime = new Date (); var NMS =endtime-nowtime.gettime (); var Nm=math.floor (nms/(1000*60))% 60; var ns=math.floor (nms/1000)% 60; if (nm==0&&ns==0&&nms<1000)//When the countdown is over { Window.focus (); SetInterval ("blinknewmsg ()", 1000); Window.location.reload (); } if (ns < NS) = "0" + ns;
if (NMS >= 0) { document.getElementById ("Remaintime"). Innerhtml= NM + "min" + NS + "seconds"; SetTimeout ("Getremaintime ()", 1000); }
}
function blinknewmsg () { Document.title = g_blinkswitch% 2==0? ""-"+ G_blinktitle:" "New Message"-"+ G_blinktitle; g_blinkswitch++; }
Window.onload=getremaintime;
</script> <strong id= "Remaintime" >10 minute 00 sec </strong> |
Example 2
Countdown Jump Page
| code is as follows |
copy code |
<TITLE>JS Countdown page Auto Jump code </title> <script language= "JavaScript" type= "Text/javascript" > function Delayurl (URL) { var delay = document.getElementById ("Time"). InnerHTML; if (Delay > 0) { delay--; document.getElementById ("Time"). InnerHTML = delay; } else { Window.top.location.href = URL; } SetTimeout ("delayurl (' + URL + ')", 1000); } </script> <span id= "Time" style= "background: #00BFFF" >3</span> seconds after automatic jump, if not jump, please click the link below <a href= "http:// Www.111cn.net "> My Baidu </a> <script type= "Text/javascript" > Delayurl ("Http://www.111cn.net"); </script> |
Anti-Refresh Countdown code
| The code is as follows |
Copy Code |
| <! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/> <title> www.111cn.net</title> <body> <script language= "JavaScript" > <!-- var maxtime; if (window.name== ') { MaxTime = 1*60; }else{ MaxTime = Window.name; } function Countdown () { if (maxtime>=0) { minutes = Math.floor (MAXTIME/60); seconds = Math.floor (maxtime%60); msg = "Distance to the end of the exam and" +minutes+ "+seconds+" "Seconds"; document.all["Timer"].innerhtml = msg; if (MaxTime = = 5*60) alert (' Note, there are 5 minutes! '); --maxtime; Window.name = MaxTime; } else{ Clearinterval (timer); Alert ("Test time to, end!"); } } Timer = SetInterval ("Countdown ()", 1000); --> </SCRIPT> <div id= "Timer" style= "color:red" ></div> </body> |