Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Countdown timer?

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.

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

like image 818
001 Avatar asked Dec 29 '22 17:12

001


1 Answers

Something like this?

   <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>
like image 141
rob Avatar answered Dec 31 '22 07:12

rob