Determine whether webpage has foreground window focus/is active tab?
I'd like to be able to mute activity of my app if I can detect that the page is no longer focused. For instance, if the page is in a background tab or another app has focus, I'd like to disable a constantly polling script or switch modal notifications to the new HTML5 notifications API. Is there any way to get this with JS, and if so, w...