Skip to content

Commit

Permalink
add window alert when user try to close without saving
Browse files Browse the repository at this point in the history
  • Loading branch information
CyberSphinxxx committed Sep 17, 2024
1 parent 1364225 commit fb4c3a9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,3 +333,11 @@ document.addEventListener('fullscreenchange', () => {

// Initialize the editor with the first tab content
editor.setValue(tabs[0].content, -1);

// Alerts the user when you try to leave
window.addEventListener('beforeunload', function (e) {
const confirmationMessage = "The changes you made may not be saved.";
e.preventDefault();
e.returnValue = confirmationMessage;
return confirmationMessage
});

0 comments on commit fb4c3a9

Please sign in to comment.