Fix window close warning

The code didn't follow current API for the beforeunload event.
This commit is contained in:
Samuel Mannehed 2016-08-25 15:32:15 +02:00
parent 9d16e512ba
commit b9efece4a8
1 changed files with 8 additions and 2 deletions

View File

@ -156,9 +156,15 @@ var UI;
Util.addEvent(window, 'load', UI.keyboardinputReset); 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 () { Util.addEvent(window, 'beforeunload', function () {
if (UI.rfb && UI.rfb_state === 'normal') { 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
} }
}); });