I would like to tell whether my browser's tab is in focus, and whether the browser itself is in the foreground or in the background.
Is there a javascript interface that queries the foreground/background status of the browser?
Update Following Palpatim's answer below, I found this practical HTML5Rocks tutorial about the page visibility API.