title: Detecting lost window focus in Google Chrome
body: <p>I need to know via javascript whether a page has focus or not.</p>
  
  <p>When the user switches to another tab, minimizes the browser, or clicks outside the browser, the page shouldn't have focus.</p>
  
  <p>When the user returns to the window, by opening it, returning to the tab, clicking on the page, the page needs to have focus.</p>
  
  <p>The problem is the method must correctly report whether the page has focus or not when there is a flash swf on the page that may or may not have focus and I don't have control of the swf content.</p>
  
  <p>The window's focus needs to be independent of the flash swf's focus. So when the swf has focus, the user leaves the browser whilst the flash swf has focus, or when the user returns directly to the swf, the window's focus must be reported correctly.</p>
  
  <p>I have methods of doing this in FireFox 3.0, 3.5, IE 6, 7, 8, Safari 4.0.3, 4.0.4, Opera 9.0+.</p>
  
  <p>The standard focus/blur window events do not work properly in Google Chrome. When the flash swf gains focus, the window loses it (the window blur event is triggered). This is not desired.</p>
  
  <p>I need a method that will work in Google Chrome 3 and 4.</p>
  
  <p>Ideally, I would also like a method that works in FireFox 2 and Safari &lt; 4.0.3. In these browsers, focus/blur do not work either as if the flash swf has focus and you leave the window, the blur window event is not triggered at all.</p>