mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2024-11-25 09:19:23 +01:00
Add beforeunload event to add confirmation dialog when leaving page (#6279)
This commit is contained in:
parent
0f90a1b50f
commit
e4b0467f9f
11
js/main.js
11
js/main.js
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user