mirror of
https://github.com/kou029w/quot.git
synced 2025-01-19 00:18:09 +00:00
18 lines
351 B
TypeScript
18 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;
|