1
0
Fork 0
mirror of https://github.com/kou029w/quot.git synced 2025-01-19 16:38:06 +00:00
quot/app/views/helpers/beforeunload.ts

19 lines
351 B
TypeScript
Raw Normal View History

2022-08-24 09:50:35 +09:00
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;