2
Explaining the problem
I’m working with sockets, and would like to know how to put a notification only when the tab is out of focus.
That is, when the user is viewing the tab, he will not receive notifications, but if he leaves that tab, he will receive new notifications
What I really need is a function similar to .blur()
jquery, but this function needs to function as a Listener, that is, it stays there always activated waiting for something to happen. The problem of .blur()
is that it is fired only when the window loses focus.
$(window).blur(function(){
console.log("Isto será executado apenas quando eu clicar em outra tab")
}
In short
I need a function that runs on tabs that are not in user focus as it receives new notifications in real time.
Can be Javascript or Jquery.