watcher.addEventListener("cancel", (e) => {
if (e.cancelable && hasUnsavedData) {
const userReallyWantsToClose = confirm("Are you sure you want to close?");
if (!userReallyWantsToClose) {
e.preventDefault();
}
}
});
// Trigger a close request manually
watcher.requestClose();CloseWatcher: cancel event / notebook
CloseWatcher: cancel event
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.