Testing if a webpage is in focus or not

External references:

This seems to detect both the "tab" and "browser" focus states; if this page is open in your browser, but another program has OS focus, then this will report as 'blurred'.

Here's a link to this page, useful for R-Click->open in tab testing.

Notes about focus/blur behaviour

Notes about requestAnimationFrame in requestanimationframe.html

Browser Normal page load Page reload Page loaded in background tab
Firefox 10 Gets focus as soon as the page loads Gets focus as soon as the page loads Gets focus as soon as you click on the tab
Opera 11.61 Status is unknown by default, only changes when another window gains focus, or you click on the input box (doesn't do anything if you just click on an arbitrary point on the page Status is unknown by default, only changes when another window gains focus, or you click on the input box (doesn't do anything if you just click on an arbitrary point on the page Gets focus as soon as you click on the tab
Chromium 15 Status is unknown by default; only changes when another window gains focus. DOES NOT change if you click anywhere on the page, including in the input box, and not even if you enter something in the text box. Status is unknown by default; only changes when another window gains focus. DOES NOT change if you click anywhere on the page, including in the input box, and not even if you enter something in the text box. Starts off unfocussed, does gain focus as soon as you click on the tab
Debug messages will appear here