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
1 changed files with 6 additions and 0 deletions

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;