1
0
mirror of https://git.tuxpa.in/a/code-server.git synced 2024-12-27 20:55:25 +00:00

Add confirmation for closing window (#463)

* Add confirmation for closing window

* Make function an event listener for consistency

* Change let to const

* Refactor for compatability
This commit is contained in:
John McCambridge 2019-04-17 16:42:36 -05:00 committed by Kyle Carberry
parent 630ccfcacc
commit 50e6108012

View File

@ -34,6 +34,12 @@ export abstract class IdeClient {
this.loadTime = time(2500); this.loadTime = time(2500);
let appWindow: Window | undefined; let appWindow: Window | undefined;
window.addEventListener("beforeunload", (e) => {
e.preventDefault(); // FireFox
e.returnValue = ""; // Chrome
});
window.addEventListener("message", (event) => { window.addEventListener("message", (event) => {
if (event.data === "app") { if (event.data === "app") {
appWindow = event.source as Window; appWindow = event.source as Window;