-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Description
class PreventClose extends HTMLElement {
// set up events
connectedCallback() {
// disable on localhost for david's sanity
if (window.location.host.includes("localhost")) {
return;
}
this.beforeUnloadListener = (event) => {
event.preventDefault();
return (event.returnValue =
"Are you sure you want to exit? There are unsaved changes.");
};
addEventListener("beforeunload", this.beforeUnloadListener, {
capture: true,
});
}
disconnectedCallback() {
removeEventListener("beforeunload", this.beforeUnloadListener, {
capture: true,
});
}
}
customElements.define("prevent-close", PreventClose);Metadata
Metadata
Assignees
Labels
No labels