title: jQuery timer pauses when browser is out of focus
body: <p>I'm facing this problem in Chrome and Mozilla, while IE works fine. The timer pauses when I minimize the browser or open a new tab and work on that tab for a while, but then resumes again if the web application is in focus again. I know this by the difference in the time, e.g. after about a minute or so only a second or so will have elapsed when I return to the web application. I don't know what is causing this issue.</p>
  
  <p>Here is the jQuery snippet that I used, the timer can be downloaded from here <a href="http://code.google.com/p/jquery-timer/" rel="nofollow">http://code.google.com/p/jquery-timer/</a></p>
  
  <pre><code> var countdownTimer, countdownCurrent;
      $(document).ready(function () {
          countdownCurrent = $('#ctl00_MainContent_example2submit').val() * 100;
          countdownTimer = $.timer(function () {
              var min = parseInt(countdownCurrent / 6000);
              var sec = parseInt(countdownCurrent / 100) - (min * 60);
              var micro = pad(countdownCurrent - (sec * 100) - (min * 6000), 2);
              var output = "00"; if (min &gt; 0) { output = pad(min, 2); }
              $('.countdowntime').html(output + ":" + pad(sec, 2) + ":" + micro);
              if (countdownCurrent == 0) {
                  $('#ctl00_MainContent_btnNext').click();
  
              } else {
                  countdownCurrent -= 7;
                  if (countdownCurrent &lt; 0) { countdownCurrent = 0; }
              }
          }, 70, true);
  
  
          $('#example2submit').bind('keyup', function (e) { if (e.keyCode == 13) { countdownReset(); } });
  
      });
  
      function CheckIfOptionSelected() {
  
          var vFlag = true;
          var radioButton1 = document.forms[0].elements['ctl00_MainContent_rdBtnListOptions_0'];
          var radioButton2 = document.forms[0].elements['ctl00_MainContent_rdBtnListOptions_1'];
          var radioButton3 = document.forms[0].elements['ctl00_MainContent_rdBtnListOptions_2'];
          var radioButton4 = document.forms[0].elements['ctl00_MainContent_rdBtnListOptions_3'];
  
          if (radioButton1.checked == false &amp;&amp; radioButton2.checked == false &amp;&amp; radioButton3.checked == false &amp;&amp; radioButton4.checked == false &amp;&amp; countdownCurrent &gt; 0) {
              vFlag = false;
          }
  
          else {
              countdownReset();
              vFlag = true;
          }
          return vFlag;
      }
  
      function countdownReset() {
          var newCount = parseInt($('#ctl00_MainContent_example2submit').val()) * 100;
          if (newCount &gt; 0) { countdownCurrent = newCount; }
          countdownTimer.stop().once();
                  }
  
      // Padding function
      function pad(number, length) {
          var str = '' + number;
          while (str.length &lt; length) { str = '0' + str; }
          return str;
      }
  </code></pre>