beforeunload update

This commit is contained in:
duanyu5871 2025-10-12 13:53:39 +00:00
parent 8184ba800b
commit 84d09b8e0f
2 changed files with 6 additions and 0 deletions

View File

@ -1159,6 +1159,11 @@ class EmulatorJS {
}, 0);
});
this.addEventListener(window, "beforeunload", (e) => {
if (window.EJS_askBeforeUnload) {
e.preventDefault();
e.returnValue = '';
return
}
if (!this.started) return;
this.callEvent("exit");
});

View File

@ -259,6 +259,7 @@
window.EJS_DEBUG_XX = enableDebug;
window.EJS_disableDatabases = true;
window.EJS_threads = enableThreads;
window.EJS_askBeforeUnload = false;
if (browserMode) {
window.EJS_browserMode = browserMode;
}