JavaScript Countdown Jump Page Instance

Source: Internet
Author: User
Tags setinterval

In JS to achieve page timing jump we want to use the SetInterval or settimeout function, of course, you can also use the Metea implementation of the page, I introduce the following two examples.

Example 1

Countdown Refresh Page

The code is as follows

<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"-"+



<strong id= "Remaintime" >10 minute 00 sec </strong>

Example 2

Countdown Jump Page

The code is as follows

<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) {
document.getElementById ("Time"). InnerHTML = delay;
} else { = URL;
SetTimeout ("delayurl (' + URL + ')", 1000);
<span id= "Time" style= "background: #00BFFF" >3</span> seconds after automatic jump, if not jump, please click the link below <a href= "http:// "> My Baidu </a>
<script type= "Text/javascript" >
Delayurl ("");

Anti-Refresh Countdown code

The code is as follows

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http:// "> 
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/> 
<body >&NBSP
<script language= "JavaScript" > 
var maxtime; 
if ( ') { 
MaxTime = 1*60; 
MaxTime =; 

function countdown () { 
if (maxtime>=0) { 
minutes = Math.floor (MAXTIME/60);  
seconds = Math.floor (maxtime%60);  
msg = distance to the end of the exam there is also "+minutes+" +seconds+ "seconds";  
document.all["Timer". InnerHTML = msg; 
if (maxtime = = 5*60) alert (' Note, there are 5 minutes! '); &NBSP
--maxtime; = maxtime; 

ClEarinterval (timer);  
Alert ("Test time to, end!"); &NBSP

Timer = SetInterval ("Countdown ()", 1000);  
<div id= "Timer" style= "color:red" ></DIV>&NBSP;

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

11.11 Big Sale for Cloud

Get Unbeatable Offers with up to 90% Off,Oct.24-Nov.13 (UTC+8)

Get It Now >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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: and provide relevant evidence. A staff member will contact you within 5 working days.