mirror of
https://github.com/kou029w/quot.git
synced 2025-01-19 16:38:06 +00:00
19 lines
351 B
TypeScript
19 lines
351 B
TypeScript
|
function beforeunload() {
|
||
|
function listener(e: BeforeUnloadEvent) {
|
||
|
e.preventDefault();
|
||
|
e.returnValue = "";
|
||
|
}
|
||
|
|
||
|
function block() {
|
||
|
window.addEventListener("beforeunload", listener);
|
||
|
}
|
||
|
|
||
|
function unblock() {
|
||
|
window.removeEventListener("beforeunload", listener);
|
||
|
}
|
||
|
|
||
|
return { block, unblock };
|
||
|
}
|
||
|
|
||
|
export default beforeunload;
|