Parcourir la source

Minor improvement of websocket handling

Alexey Edelev il y a 5 ans
Parent
commit
9c5168a9ce
1 fichiers modifiés avec 5 ajouts et 2 suppressions
  1. 5 2
      web/js/index.js

+ 5 - 2
web/js/index.js

@@ -520,9 +520,12 @@ function connectNotifier() {
     }
 }
 
-window.onbeforeunload = function() {
+$(window).on('beforeunload', function(){
     if (notifierSocket != null) {
-        notifierSocket.onclose = function () {}; // disable onclose handler first
         notifierSocket.close();
+        notifierSocket = null
     }
+});
+
+window.onbeforeunload = function() {
 };