Created
January 15, 2014 14:22
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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