Ответ 1
События размытие и фокус могут определять состояние просмотра окна.
Пример:
var timer = null;
//when the window is minimized or when user is in different tab .
window.addEventListener('blur', function(){
timer = setInterval(function(){
window.location.reload(1);
},5000)
}, false);
//when user is back to window
window.addEventListener('focus', function(){
//stop the page reload once
if(timer != null){
clearInterval(timer);
}
}, false);
Надеюсь, что это поможет.