Javascript automatically redirects to the code after the countdown N seconds
Copy codeThe Code is as follows:
<Title> JS countdown webpage automatic 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;
}
T = setTimeout ("delayURL ('" + url + "')", 1000 );
}
Function stop1 (){
T & clearTimeout (t );
}
</Script>
<Span id = "time" style = "background: #00 BFFF"> 1000 </span> is automatically redirected in seconds, click the link below <a href = "http://www.baidu.com"> my Baidu </a>
<Input type = "button" value = "Stop Jump" onclick = "stop1 ();">
<Script type = "text/javascript">
DelayURL ("http://www.baidu.com ");
</Script>
The code is very simple, but it is very practical. You can put it in your project as needed.