summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Mannehed <samuel@cendio.se>2016-08-25 15:32:15 +0200
committerSamuel Mannehed <samuel@cendio.se>2016-08-25 15:40:11 +0200
commitb9efece4a8b896a533cfd456098246011dc35f84 (patch)
treee32d7e5a8003de9fac8ef3468b4946c416243b6e
parent9d16e512ba839108afd8a478efaf852c3ffd0404 (diff)
downloadnovnc-b9efece4a8b896a533cfd456098246011dc35f84.tar.gz
Fix window close warning
The code didn't follow current API for the beforeunload event.
-rw-r--r--include/ui.js10
1 files changed, 8 insertions, 2 deletions
diff --git a/include/ui.js b/include/ui.js
index ae2fdb6..058ae5a 100644
--- a/include/ui.js
+++ b/include/ui.js
@@ -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") {