I'm writing a turn-based game in which the server may send messages to the javascript client at random times. When the client receives these messages, it puts an asterisk at the document's title. My problem is, how do I detect that the user is viewing the page, so that I can remove the asterisk as soon as the user has seen the new messages?
For instance, how does Gmail and Facebook do it? I heard that one cannot put an onfocus
property on the body
object.
I would also like to know why the body doens't have the onfocus property.