我如何确定我是否要“前进"?或“向后"通过我在 GWT 中的历史记录? [英] How do I determine whether I am going "forward" or "backward" through my History in GWT?

查看:12
本文介绍了我如何确定我是否要“前进"?或“向后"通过我在 GWT 中的历史记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在查看 HistoryGWT 中的历史 JavaDocs 并且我注意到没有办法判断是向前还是向后按钮被按下(无论是实际按下还是由用户按下).按钮按下"由您注册的 addValueChangeHandler 处理,但传递给处理程序的唯一内容是历史堆栈中的字符串.没有关于历史"是后退"(使用后退箭头按钮)还是前进"(使用右箭头按钮)的指示.有没有办法确定这一点?

I am looking at History and History JavaDocs in GWT and I notice that there is no way to tell whether the forward or backward button was pressed (either pragmatically or by the user). The "button press" is handled by your registered addValueChangeHandler, but the only thing passed to the handler is a string on your history stack. There is no indication as to whether the "History" is moving "back" (using the back arrow button) or "forward" (using the right arrow button). Is there any way to determine this?

推荐答案

抱歉,您不能.即使可以,也有一些浏览器,例如 Firefox,可以让用户跳"回不止一页.因此,如果您尝试依赖相对坐标"而不是绝对坐标,导航可能会破坏您的应用程序.

Sorry, you can't. And even if you could, there are browsers, like Firefox, that let the user "jump" back more than one page. So if you try to relying on relative "coordinates" instead of absolute, the navigation could break your app.

您始终可以在历史令牌上附加某种计数器.如果你只有一个历史监听器,这并不难.

You can always append some kind of counter on your history token. It would not be hard, if you have only one history listener.

这篇关于我如何确定我是否要“前进"?或“向后"通过我在 GWT 中的历史记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆