I have a working chat based on Meanjs and I would like to add a new feature to it that I see on other chats available:
Feature: 1. when a message is received, the title of the window starts to switch between what it was, and a notification message like "new message" 2. when the browser or tab receives the focus, to stop the ongoing activity and reset back to the static page title
The first one is simply to have a timer and change the page title during an interval, but I don't know how to get the event of the browser getting or losing the focus.
I could simply ask "how detect focus" for the browser, but I explained my purpose to hopefully know the best practice in this particular use-case and learn more.
Will welcome and appreciate lessons.