Reputation: 3817
I'm using function
$(window).on("blur focus", function(e) {
var prevType = $(this).data("prevType"); // getting identifier to check by
if (prevType != e.type) { // reduce double fire issues by checking identifier
switch (e.type) {
case "blur":
flashTitle(from + " messaged you", 500);
break;
case "focus":
cancelFlashTitle();
break;
}
}
$(this).data("prevType", e.type); // reset identifier
})
I want the flash title triggered ONLY when the user is not looking at the tab. Means like the tab is not focused now. Right now the flash title triggered only when I focus the tab first and then leave(blur) it.
Any ideas? Thank you :-)
Upvotes: 0
Views: 165
Reputation: 49
It sounds like you would want to flash the title upon getting a new message if the tab is not focused, since the message is the event that's happening, and then cancel any flashing on focus.
Upvotes: 1