title: Is there an event in Javascript that fires when user changes tabs in browser
body: <p>Let me start with the problem: Chrome behaves strange when using setTimeout() if the user changes browser tabs, the executing of the Javascript is halted/pauzed. After the user changes back, Chrome wants to catch up, so the animation isn't respecting the timneout and is animating out of control.</p>
  
  <p>I'm trying to prevent Chrome from rushing the animation if the user comes back after a while. I've found in another question that jQuery offers a .blur &amp; .focus event, but that doens't seem to work either:</p>
  
  <pre><code>$(window).blur(function() {
    clearTimeout(timer) 
  })
  </code></pre>
  
  <p>Is there any way to stop the animation on the exact moment that the user changes the tabs, or is there no event that gets fired just after the user changes tabs?</p>