Disable back button in GWT

前端 未结 5 579
旧时难觅i
旧时难觅i 2021-01-15 14:28

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

5条回答
  •  Happy的楠姐
    2021-01-15 14:41

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

    That is not a fool proof solution. In fire fox I can press the back button and the onWindowClosing method is never invoked. The reason is that I have used History.newItem() and since history exists the back button or backspace buttons simply navigate through the browser history.

    So....fix that :)

提交回复
热议问题