Javascript count and redirect page after second

January 21, 2016
over-www
Category: Scripts

Refer to link: http://www.apphp.com/index.php?snippet=javascript-redirect-with-timer

  1. <script type=“text/javascript”>
  2. var count = 6;
  3. var redirect = “http://www.apphp.com”;
  4. function countDown(){
  5.     var timer = document.getElementById(“timer”);
  6.     if(count > 0){
  7.         count–;
  8.         timer.innerHTML = “This page will redirect in “+count+” seconds.”;
  9.         setTimeout(“countDown()”, 1000);
  10.     }else{
  11.         window.location.href = redirect;
  12.     }
  13. }
  14. </script>
  15. Our webpage has beed moved. Please update your bookmarks for the new site.
  16. <br>
  17. <span id=”timer”>
  18. <script type=“text/javascript”>countDown();</script>