views:

283

answers:

2

Hi Folks,

I have a JavaScript chat client running in one browser tab (call it tab A). Now when a message arrives the user might be on another browser tab (call it tab B). I'm looking for ways to change the focus from tab B to my chat client (tab A) when such a message arrives. I could not find a way to do this. Any idea?

Thanks, Max

+2  A: 

It is not possible - due to security concerns.

unless by "tab" you mean a window and a popup window that (due to browser preferences) opened up in a new tab. If this is the case, then yes you can.

//focus opener... from popup
window.opener.focus();

//focus popup... from opener
yourPopupName.focus(); 
scunliffe
+1  A: 

The best you could would probably be to change the title of the page alerting the user the tab needs attention (maybe also the favicon - look at how meebo does it, it's really annoying but effective)

nc3b
Twitter does something similar in that it adds a count if there are new messages to be read, so I agree that's probably the best way to go.
mattbd