Warning prior to closing a document with unsaved changes. Ist it possible?

Hi all,

is it possible to warn a user with a pop-up window prior to leaving a document if there are unsaved changes in the document?

Thanks!
Dominik

Hi,
it is possible by customizing it according requirements & You can give pop up message only on save or submit click events or on back button of browser.

This can be achieved using onbeforeunload event - Prevent leaving the page using plain JavaScript

1 Like

Thanks for the info!!

Does anybody have an implementation for this ready?

I have

If this is still relevant to you, you might extend your Core Code manually with my code

refresh: function(frm) {
        window.onbeforeunload = function() {
                if(frm.is_dirty()){ return 'A valid String';}
                else { return; }
        }
}

This is already there in v14. Upgrade! :smile:

Also on 13.33+

PR from @tomf feat(UI): Add beforeunload Listener for 'Leave Site' Dialog to dirty forms by Tom-Finke · Pull Request #17059 · frappe/frappe · GitHub