I have JavaScript that is doing activity periodically. When the user is not looking at the site (i.e., the window or tab does not have focus), it\'d be nice to not run.
I would use jQuery because then all you have to do is this:
$(window).blur(function(){ //your code here }); $(window).focus(function(){ //your code });
Or at least it worked for me.