title: Continuous Countdown Timer In Javascript or Jquery
body: <p>I want to create a simple countdown timer in javascript or jquery.</p>
  
  <p>I had implemented it using JS but what issue I am facing is if user refreshes the page then timer gets the refresh.</p>
  
  <p>What I want is timer should not get the refresh.
  Say timer is 5 min and if user refresh pages after 1 min the timer should continue to start from 4 min instead of 5 mins.
  Here is code snippiet. 
  Its refresh the timer on page refresh.
  <div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var timeoutHandle;
  function countdown(minutes) {
      var seconds = 60;
      var mins = minutes
      function tick() {
          var counter = document.getElementById("timer");
          var current_minutes = mins-1
          seconds--;
          counter.innerHTML =
          current_minutes.toString() + ":" + (seconds &lt; 10 ? "0" : "") + String(seconds);
          if( seconds &gt; 0 ) {
              timeoutHandle=setTimeout(tick, 1000);
          } else {
  
              if(mins &gt; 1){
  
                 // countdown(mins-1);   never reach “00″ issue solved:Contributed by Victor Streithorst
                 setTimeout(function () { countdown(mins - 1); }, 1000);
  
              }
          }
      }
      tick();
  }
  
  countdown(2);</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="timer"&gt;2:00&lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>