Home > Net >  How can I show a confirm dialog with Vaadin 23 when the user clicks on back button?
How can I show a confirm dialog with Vaadin 23 when the user clicks on back button?

Time:01-11

how can I show a dialog to stay or leave the current page with Vaadin 23, when a user clicks back button on browser?

Regards

CodePudding user response:

You simply can't do that. If disabling back button is important for you, the only way is to enforce your users to use the application via desktop shortcut which starts the app using --app paramater (if using Chrome). This is not a limitation in Vaadin, but a general restriction in browser behavior.

CodePudding user response:

It depends what you wish to achieve.

See this older discussion: Vaadin onbeforeunload event

Generally: use the onBeforeUnload javascript even for this https://www.w3schools.com/tags/ev_onbeforeunload.asp

This is executed when the user would go away from your vaadin app, but not when using the back button inside your vaadin app.

For these you can use the navigation lifecycle events as documented here https://vaadin.com/docs/latest/routing/lifecycle

Not sure if it also catches, when a user leaves your app...

  • Related