Is it possible to add pop up to confirm exit?

If a user accidentally exits without pressing the “Save” button at least once

import panel as pn
pn.extension()
button = pn.widgets.Button(name="Save")
# make sure save was clicked at least once; if not console.alert(?) about exiting

Hi @ahuang11. Did you ever find a solution to this?

    exit_prompt = pn.pane.HTML(
        """
        <script>
        window.onbeforeunload = function () {
        return "This message doesn't actually appear but the prompt does";
        };
        </script>
        """
    )

Putting something like this anywhere in your app solved this problem for me

2 Likes