mirror of
https://github.com/EmulatorJS/EmulatorJS.git
synced 2026-02-06 03:06:57 +00:00
beforeunload event listener update (#1107)
* beforeunload update * Rename to EJS_disableAutoUnload * Remove value from index.html since undefined is a falsy value --------- Co-authored-by: Ethan O'Brien <ethan.a.obrien@gmail.com> Co-authored-by: Ethan O'Brien <77750390+ethanaobrien@users.noreply.github.com>
This commit is contained in:
parent
54d7dfbc1f
commit
c0480f888d
@ -127,6 +127,7 @@
|
||||
config.browserMode = window.EJS_browserMode;
|
||||
config.shaders = Object.assign({}, window.EJS_SHADERS, window.EJS_shaders ? window.EJS_shaders : {});
|
||||
config.fixedSaveInterval = window.EJS_fixedSaveInterval;
|
||||
config.disableAutoUnload = window.EJS_disableAutoUnload;
|
||||
|
||||
let systemLang;
|
||||
try {
|
||||
|
||||
@ -1159,6 +1159,11 @@ class EmulatorJS {
|
||||
}, 0);
|
||||
});
|
||||
this.addEventListener(window, "beforeunload", (e) => {
|
||||
if (this.config.disableAutoUnload) {
|
||||
e.preventDefault();
|
||||
e.returnValue = "";
|
||||
return
|
||||
}
|
||||
if (!this.started) return;
|
||||
this.callEvent("exit");
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user