Skip to content

Instantly share code, notes, and snippets.

@RyannosaurusRex
Created January 15, 2014 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RyannosaurusRex/8437128 to your computer and use it in GitHub Desktop.
Save RyannosaurusRex/8437128 to your computer and use it in GitHub Desktop.
Notify a user who has minimized a window when a message or event has arrived. The blur/focus is to ensure that the javascript message is not fired when a user is on the screen, to minimize annoyances of closing the popup window.
var inFocus = true;
$(window).blur(function(){
inFocus = false;
});
$(window).focus(function(){
inFocus = true;
});
setTimeout(function(){
if (!inFocus) {
alert('New Message!');
}
}, 6000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment