Disable back button in GWT

gwt, java, javascript

Solution

You cannot disable a button just intercept it and change its return to something the browser does not understand.

This removes the history:

 Window.addWindowClosingHandler(new ClosingHandler() {
     @Override
      public void onWindowClosing(ClosingEvent event) {
      event.setMessage("My program");
      }
    }); 

To understand it see: http://groups.google.com/group/google-web-toolkit/browse_thread/thread/8b2a7ddad5a47af8/154ec7934eb6be42?lnk=gst&q=disable+back+button#154ec7934eb6be42

However, I would recommend not doing this because your it goes against good UI practices. Instead you should figure out a way that the back button does not cause a problem with your code.

Problem

Is there a way to disable the Back button in a browser (basically clearing the History token stack) in GWT? Once I browse to a certain page in my application I want to make sure that the user can't use the back button to go back, but only be able to use links on the page to navigate the site.

Original source

Related problems