From 03d5fab794bb4c2037bb2263703ef9551c1782c5 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Wed, 18 Dec 2019 11:28:39 +0200 Subject: [PATCH] Fix beforeunload not working --- client/js/socket-events/configuration.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client/js/socket-events/configuration.js b/client/js/socket-events/configuration.js index 9c3e4eec..72b58f86 100644 --- a/client/js/socket-events/configuration.js +++ b/client/js/socket-events/configuration.js @@ -26,9 +26,9 @@ socket.once("configuration", function(data) { } if (document.body.classList.contains("public")) { - window.addEventListener( - "beforeunload", - () => "Are you sure you want to navigate away from this page?" - ); + window.addEventListener("beforeunload", (e) => { + e.preventDefault(); + e.returnValue = "Are you sure you want to navigate away from this page?"; + }); } });