Si Browsertab est actif jQuery
document.addEventListener('visibilitychange', function() {
if(document.hidden)
console.log('Page is hidden from user view');
else
console.log('Page is in user view');
});
Bad Bear