I'm coding part of a chat system for a community, and have run into a problem with popup blocking I'd like some advice on. What happens is
User A klicks to send a chat request ot user B
An ajax request is sent to check that A and B are allowed to chat (user settings, both online etc)
If everything is OK, a new window containing the chat client should open
The problem is, that the response from the ajax request is handled by an event handler function, and even though the action is obviously initiated by the user (click), some (all?) browsers entirely disregards this and blocks the new window as if it was opened through a body onload or similar; assuming the user has enabled popup blocking. Do note that opening a new window as the (direct) result of a button click still works.
The same problem arises when user B accepts the chat request.
This browser behaviour is bad according to me, but whatever I feel, what I need is a way to deal with this. The two possible ways I see myself are
But, using SJAX, the browser will hang while waiting for the response. Sure, it should be quick enough almost all of the time, but what about those times when it's not?
Opening a new window directly, and thereafter check if the users are allowed to chat should work most of the time, but what about those times when the other user just logged off, changed settings for whom are allowed to send chat requests etc. In these cases the one sending the request will have a useless window pop up for no good reason.
Any other ways to deal with this? Or any other suggestions on how to improve this. Btw, cramming the chat client into the existing page is not a good alternative, since it's not just a text chat, but also video chat, and the client doesn't fit in any good way with the existing community UI, which is why we opted for a new window.