Take the 2-minute tour ×

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 after clicking the button, my url SHALL be

But so far, this is not working :(

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

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


see Documentation

share|improve this answer
String newUrl = Window.Location.createUrlBuilder().setHash("newHash").buildString(); Window.Location.replace(newUrl); This way I don't alter the "back" button behavior –  qin Jul 17 '11 at 14:57
add comment

Your Answer


