]> git.proxmox.com Git - mirror_novnc.git/commitdiff
Fix window close warning
authorSamuel Mannehed <samuel@cendio.se>
Thu, 25 Aug 2016 13:32:15 +0000 (15:32 +0200)
committerSamuel Mannehed <samuel@cendio.se>
Thu, 25 Aug 2016 13:40:11 +0000 (15:40 +0200)
The code didn't follow current API for the beforeunload event.

include/ui.js

index ae2fdb675666991920e3eb2f787d751efa9b20b1..058ae5a41dd90eedfd42b2c1e1b89c4b9f7b2a15 100644 (file)
@@ -156,11 +156,17 @@ var UI;
 
             Util.addEvent(window, 'load', UI.keyboardinputReset);
 
+            // While connected we want to display a confirmation dialogue
+            // if the user tries to leave the page
             Util.addEvent(window, 'beforeunload', function () {
                 if (UI.rfb && UI.rfb_state === 'normal') {
-                    return "You are currently connected.";
+                    var msg = "You are currently connected.";
+                    e.returnValue = msg;
+                    return msg;
+                else {
+                    return void 0; // To prevent the dialogue when disconnected
                 }
-            } );
+            });
 
             // Show description by default when hosted at for kanaka.github.com
             if (location.host === "kanaka.github.io") {