sockjs closing before onbeforeunload

46 views
Skip to first unread message

Chris-S

unread,
Mar 25, 2014, 10:32:43 PM3/25/14
to soc...@googlegroups.com
I'm using a check to make sure the user understands they are in the middle of a game when they hit exit

window.onbeforeunload = function() {
if(ConditionJoined)
return "Leaving this page will close any games or chats launched from this room";
}

But when when I click the browsers alert to stay on the same page. socket.onclose is fired.

I have no other occurrences of onbeforeunload.

Chris-S

unread,
May 25, 2014, 5:41:39 AM5/25/14
to soc...@googlegroups.com
BUMP!

I've been forced to comment out line 569 and 570
// utils.attachEvent('beforeunload', unload_triggered);
// utils.attachEvent('unload', unload_triggered);

This allows my client code to hook into onbeforeclose & onclose to send a [WINDOW_CLOSING] msg to the server, I then call sock.close()

Is this safe to do? and or is there a better way - such as an option to disable or hook into?

Bryce Kahle

unread,
May 25, 2014, 11:42:11 AM5/25/14
to soc...@googlegroups.com
There isn't any code to attach to 'beforeunload' in the library. Did you add that yourself?
Reply all
Reply to author
Forward
0 new messages