I have a series of pages that open popups (new tabs in Mobile Safari.) Each of these popups needs to know when they are the focused or not. On desktops, we use window.
window.
Try this: https://gist.github.com/1122546
It's a Visibilty API polyfill. Should do the trick.