倒数计时器? [英] Countdown timer?

查看:162
本文介绍了倒数计时器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你怎么做一个倒数计时器?

How do you make a Countdown timer?

当用户加载页面时,时钟开始倒数计时,到达时间,它会重定向浏览器到一个新的页面。

When the user loads the page, clock starts counting down, it reaches time, it redirects browser to a new page.

发现这个,这不是太有用。 http://encosia.com/ 2007/07/25 /显示,数据更新,在实时与 - 阿贾克斯/

Found this, it was not too useful. http://encosia.com/2007/07/25/display-data-updates-in-real-time-with-ajax/

推荐答案

这样的事情?

   <div id="countDiv"></div>

    <script>
    function countDown (count) {
      if (count > 0) {
       var d = document.getElementById("countDiv");
       d.innerHTML = count;
       setTimeout (function() { countDown(count-1); }, 1000);
       }
      else
       document.location = "someotherpage.html";
    }
    countDown(5);
    </script>

这篇关于倒数计时器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆