简体   繁体   English

如何在gwt中处理浏览器事件?

[英]How to handle browser event in gwt?

I am using GWT 2.3 with GWTP plugin in my application.In this application I want to block browser back and forth event.For this I got some java script code.But this code is onLoad() and onUnLoad() of the html page.As application is a GWT application there is only one html which myapplication.html.So it is loaded only one time rest history token fire depends upon code. 我在我的应用程序中使用GWT 2.3和GWTP插件。在这个应用程序中我想阻止浏览器来回事件。为此我得到了一些java脚本代码。但是这个代码是html页面的onLoad()和onUnLoad()。由于应用程序是一个GWT应用程序,myapplication.html只有一个html。因此只加载一次休息历史记录令牌依赖于代码。 I want to block browser event for each and every history token in the system. 我想阻止系统中每个历史记录的浏览器事件。

Scenario is like below: 场景如下:

My first history token is index.So first my index page is loaded.Now there is login panel on index page.After success full login I fire another history token named userpage .So my user page is loaded.On back click a history token index is fired again my index page loaded again.And now If I click on forth of browser then again my user page is loaded. 我的第一个历史记录是index.So首先我的索引页面被加载。现在索引页面上有登录面板。成功完全登录后,我发出另一个名为userpage的历史记录标记。所以我的用户页面被加载。然后再点击历史记录标记索引再次被解雇我的索引页面再次加载。现在如果我点击浏览器的第四个然后再次加载我的用户页面。

So for back I don't want to fire last history token again and same for the forth not next history token. 因此,对于后面我不想再次触发上一个历史记录令牌,并且对于第四个未下一个历史记录令牌也是如此。 If history token would fired from code instead of browser event (back and forth) then it should work in proper manner.So just want to handle browser event. 如果历史令牌会从代码而不是浏览器事件(来回)触发,那么它应该以正确的方式工作。所以只想处理浏览器事件。

For handling history I also overridden method on value change.So my every history token is went to on Value change but I am not able to identify, that the history token is fired is from browser event or from code. 为了处理历史,我还覆盖了值更改的方法。所以我的每个历史记录都转到了值更改但我无法识别,历史记录令牌是来自浏览器事件或代码。

Please help me out. 请帮帮我。 Thanks in advance. 提前致谢。

Short answer: don't do it, that's not how the Web works. 简短的回答:不要这样做,这不是网络的运作方式。

Longer answer already given on the Google Group: https://groups.google.com/d/msg/google-web-toolkit/ek5cGCJ7-ug/HJEC2HTgT-AJ 谷歌集团已经给出了更长的答案: https//groups.google.com/d/msg/google-web-toolkit/ek5cGCJ7-ug/HJEC2HTgT-AJ

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM