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

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;