I have a web-based game for two players. When the first player enters, he/she has to wait for a second player to enter, which may take several minutes. I noticed that people get bored waiting, and just leave the game after several minutes. So, I thought maybe I should tell them they can do something else, and the game will notify them when the second player comes in. My question is, what type of alert to use?

A Javascript "alert" popup? This will work only if the browser window is in focus. But if the user switches to a word processor (for example), the alert will not bring the browser window to focus (at least with Firefox), so the user will miss it.

A beep? This will work only if the speakers of the user are on. Also, there might be compatibility problems between browsers and operating systems.

3 Answers
3

In the absence of something like the Web Notifications API, this will be difficult to implement in a 'nice' way. You could modify the window title, perhaps causing it to 'flash' with a notification, which might catch the user's eye if it were shown in the browser tab or taskbar.

Thinking outside the box, could you consider sending an alert through other channels that your user is likely to be monitoring? Could you perhaps offer to send a tweet, for example?

You could animate the browser tab so that it stands out and alerts the user. An example of a site which does it is Omegle which informs users by the tab animation that a chat is ready.

An alternate option is to show an update on the browser title like how facebook or gmail do it when you have a chat or a notification

This article gives has some interesting thoughts about how facebook uses tab updates to inform users alerts

Facebook’s solution to this loss of potential clicks is to get users
to view each alert as it happens, before more can stack up. These new
browser tab notifications aid this, drawing attention to Facebook even
amongst a sea of open tabs. Browser tab alerts facilitate Facebook’s
evolution from a visited destination like a web page, to a utility
frequently left open in the browser, like email. The change also
equalizes the three alert channels even though most users get many
more notifications than messages or friend requests.