开发者

Gwt using JSNI to manipulate window.location.hash

What I am want to do is really simple. I have an gwt app with just one button, everytime I click the button, I want my window.location.hash changed.

here is what I have so far


private native void setLocationHash() /*-{
   var hash = window.location.hash;
   window.location.hash = hash+1;
}-*/;

So every time my button click event fires, that JSNI function would be called. Suppose before button click, my url is http://127.0.0.1:8888/GwtSampleApp开发者_如何学Go.html?gwt.codesvr=127.0.0.1:9996#1 after clicking the button, my url SHALL be http://127.0.0.1:8888/GwtSampleApp.html?gwt.codesvr=127.0.0.1:9996#2

But so far, this is not working :(


You don't need to use JSNI as GWT has the History class for your purpose.

History.newItem("you_hash_here");

see Documentation

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜