diff --git a/lib/socket.js b/lib/socket.js index db7ae5d9..463b58ef 100644 --- a/lib/socket.js +++ b/lib/socket.js @@ -52,8 +52,7 @@ if (this.options['sync disconnect on unload'] && (!this.isXDomain() || io.util.ua.hasCORS)) { var self = this; - - io.util.on(global, 'unload', function () { + io.util.on(global, 'beforeunload', function () { self.disconnectSync(); }, false); } @@ -362,11 +361,12 @@ , this.options.host + ':' + this.options.port , this.options.resource , io.protocol + , '' , this.sessionid - ].join('/') + '?disconnect'; + ].join('/') + '/?disconnect=1'; - xhr.open('GET', uri, true); - xhr.send(null); + xhr.open('GET', uri, false); + xhr.send(null); // handle disconnection immediately this.onDisconnect('booted');