Home > Web Front-end > JS Tutorial > Implementing web page countdown automatic jump code based on JavaScript_javascript skills

Implementing web page countdown automatic jump code based on JavaScript_javascript skills

WBOY
Release: 2016-05-16 15:23:11
Original
1720 people have browsed it

Use JS to realize the automatic jump function on the web page. The countdown will jump to the specified web page. The countdown time can be set by yourself. When the time is up, it will automatically jump to the specified URL. For JS, it seems quite simple to implement this. You can also use 301 on IIS to achieve jump, and the mete tag can also achieve automatic jump, according to your own needs.

<title>JS倒计时网页自动跳转代码</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: #00BFFF">1000</span>秒钟后自动跳转,如果不跳转,请点击下面的链接<a href="http://www.baidu.com">我的百度</a>
<input type="button" value="停止跳转" onclick="stop1();">
<script type="text/javascript">
delayURL("http://www.baidu.com");
</script>
Copy after login

The above content is the JavaScript-based automatic page countdown jump code shared by the editor. I hope you like it.

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template