How to disable Browser back button in Vaadin?

Hi,
Iam buiding a secure web application using vaadin, I need to disable the browser back button is that possible in vaadin

-Hari

Hi,

it’s generally impossible to disable the back button of a browser. However, there are different kinds of hacks, for example changing the URL immediately when landing on the page.

With vaadin you could do this by setting the page’s urifragment when the UI is initialized. This would result into the user first accessing e.g. http://localhost/vaadinapp and immediately changing that to e.g. http://localhost/vaadinapp#mainpage. Now if the user presses the back button he will be taken again to http://localhost/vaadinapp. At this point you’d need to have a UriFragmentChangedListener which would again set the mainpage fragment.

The user can probably still “escape” this hack by clicking back two times very fast, or selecting some history item from the back button menu, but I think this is true for all these “no going back” type of hacks.

-tepi