mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2024-09-20 10:35:10 +02:00
Add beforeunload event to add confirmation dialog when leaving page
This commit is contained in:
parent
6bab4c2faa
commit
5d1e71ee45
1 changed files with 11 additions and 0 deletions
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 a new issue