Add beforeunload event to add confirmation dialog when leaving page

This commit is contained in:
Leszek Hanusz 2024-07-27 17:26:54 +02:00
parent 6bab4c2faa
commit 5d1e71ee45

View file

@ -600,4 +600,15 @@ headerBar.addEventListener("click", (e) => {
}
});
//------------------------------------------------
// Add a confirmation dialog when leaving the page
// Useful to avoid data loss
//------------------------------------------------
window.addEventListener('beforeunload', function (event) {
// Cancel the event
event.preventDefault();
// Chrome requires returnValue to be set
event.returnValue = '';
});
moveToChatTab();