Actually we Play a notification sound when some update happens in database, so I am trying to reload page every 5 seconds when browser in minimized, this works fine in Firefox ,
The window blur and focus events can detect the view state of the window .
Example :
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);
Hope this helps.