Example 1:
Copy the codeThe code is as follows:
<script type="text/javascript" language="JavaScript">
var startTime = new Date();
var endTime=()+10*60*1000;
var g_blinkswitch = 0;
var g_blinktitle = ;
function getRemainTime(){
var nowTime = new Date();
var nMS =endTime - ();
var nM=(nMS/(1000*60)) % 60;
var nS=(nMS/1000) % 60;
if(nM==0&&nS==0&&nMS<1000) //When the countdown ends
{
();
setInterval("blinkNewMsg()", 1000);
();
}
if(nS < 10) nS = "0" + nS;
if(nMS >= 0){
("remainTime").innerHTML= nM + "minutes" + nS + "seconds";
setTimeout("getRemainTime()",1000);
}
}
function blinkNewMsg()
{
= g_blinkswitch % 2==0 ? "【 】 - " + g_blinktitle : "【New News】 - " +
g_blinktitle;
g_blinkswitch++;
}
=getRemainTime;
</script>
<strong >10 minutes and 00 seconds</strong>
Example 2
Countdown jump page
Copy the codeThe code is as follows:
<title>JS countdown web page automatically jumps code</title>
<script language="JavaScript" type="text/javascript">
function delayURL(url) {
var delay = ("time").innerHTML;
if(delay > 0) {
delay--;
("time").innerHTML = delay;
} else {
= url;
}
setTimeout("delayURL('" + url + "')", 1000);
}
</script>
<span style="background: #00BFFF">3</span> will automatically jump in seconds. If it does not jump, please click the link below <a href="https://">My Baidu</a>
<script type="text/javascript">
delayURL("https://");
</script>
Example 3 Countdown code for anti-refresh
Copy the codeThe code is as follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:///TR/xhtml1/DTD/">
<html xmlns="http:///1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title> </title>
</head>
<body>
<SCRIPT LANGUAGE="JavaScript">
<!--
var maxtime;
if(==''){
maxtime = 1*60;
}else{
maxtime = ;
}
function CountDown(){
if(maxtime>=0){
minutes = (maxtime/60);
seconds = (maxtime%60);
msg = "There are still "+ minutes + " minutes" + seconds + " seconds" before the end of the exam;
["timer"].innerHTML = msg;
if(maxtime == 5*60) alert('Note, there are 5 minutes left!');
--maxtime;
= maxtime;
}
else{
clearInterval(timer);
alert("The exam time is up, end!");
}
}
timer = setInterval("CountDown()",1000);
//-->
</SCRIPT>
<div style="color:red"></div>
</body>
</html>
Example 4: The reality of combining pictures and numbers is more beautiful
There is a picture in the code, directly provide a demonstration address, pay attention to the image address inside
http://demo./js/2013/daojishi/