I realise that you can easily check for focus using something like this:
var hasFocus = true;
$(window).blur(function(){
hasFocus = false;
});
$(window).focus(function(){
hasFocus = true;
});
However this will still be equal to false, when the user for example has the browser window open on a second screen while working on the first screen in a different application.
This is for a real-time application that reports live data, and I don't want to be long-polling when a user has the application in a tab or minimized, but I do want to run the polling when the window is on view (even if it is not focussed).
Is there a way to check whether the window is view? (that works in older browsers preferably?)