问题描述
有没有办法在 GWT 中禁用浏览器中的后退按钮(基本上是清除历史令牌堆栈)?一旦我浏览到应用程序中的某个页面,我想确保用户无法使用后退按钮返回,而只能使用页面上的链接来导航站点.
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.
推荐答案
您无法禁用按钮,只能拦截它并将其返回更改为浏览器无法理解的内容.
You cannot disable a button just intercept it and change its return to something the browser does not understand.
这将删除历史记录:
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
但是,我建议不要这样做,因为它违背了良好的 UI 实践.相反,您应该找出一种方法,使后退按钮不会导致您的代码出现问题.
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.
这篇关于在 GWT 中禁用后退按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!