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);
let appWindow: Window | undefined;
window.addEventListener("beforeunload", (e) => {
e.preventDefault(); // FireFox
e.returnValue = ""; // Chrome
});
window.addEventListener("message", (event) => {
if (event.data === "app") {
appWindow = event.source as Window;