Seconds Countdown timer with jquery

<p>You'll be automatically redirected in <span id="count">10</span> seconds...</p>

<script type="text/javascript">

window.onload = function(){

(function(){
  var counter = 10;

  setInterval(function() {
    counter--;
    if (counter >= 0) {
      span = document.getElementById("count");
      span.innerHTML = counter;
    }
    // Display 'counter' wherever you want to display it.
    if (counter === 0) {
        alert('this is where it happens');
        clearInterval(counter);
    }

  }, 1000);

})();

}

</script>

<meta http-equiv="refresh" content="10;url=http://www.example.com" />

No comments:

Post a Comment