title: Why is $(document).blur() and $(document).focus() not working with Safari or Chrome?
body: <p>I am making a counter which counts down when document is on focus. It stops counting down when it's on blur.</p>
  
  <p>It is working in FF, but with Safari and Chrome, the counter doesn't work at all.</p>
  
  <p>Is there a compatibility problem with Safari/Chrome?</p>
  
  <p>All I'm using is <code>$(document).blur()</code> and <code>$(document).focus()</code>, and there are both within a <code>$(document).ready()</code> block. </p>
  
  <pre><code>var tm;
  $(document).ready(function(){   
  
          var seconds = 50;
          $('#timer').html(seconds);
          countdown();
  
      $(window).focus(function(){
           function countdown(){ 
           if (seconds &gt; 0) {
              seconds--; 
              $('#timer').text(seconds);
              tm = setTimeout(countdown,1000);
              }
          if (seconds&lt;=0){ 
              $('#timer').text('Go');
              }   
          }); 
  
  
  
      $(window).blur(function(){
          clearTimeout(tm);
          seconds++;
          $('#timer').text(seconds);
  
      });
  });
  </code></pre>