diff --git a/static/js/mediastream/webrtc.js b/static/js/mediastream/webrtc.js index f0c76d14..85101913 100644 --- a/static/js/mediastream/webrtc.js +++ b/static/js/mediastream/webrtc.js @@ -90,18 +90,12 @@ define([ this.api.e.bind("received.offer received.candidate received.answer received.bye received.conference", _.bind(this.processReceived, this)); - window.onbeforeunload = _.bind(function() { - if (this.currentcall) { - this.currentcall.close(); - this.api.sendBye(this.currentcall.id); - } - if (this.currentconference) { - this.currentconference.close(); - } + $(window).on("unload", _.bind(function() { + this.doHangup("unload"); if (this.api.connector) { this.api.connector.disabled = true; } - }, this); + }, this)); // Create default media (audio/video). this.usermedia = new UserMedia();