Zalivaka Zalivaka - 3 months ago 18x
HTML Question

GWT. Remove anchor part url

Hi I am using GWT and its standart way to support history via "History" class. It is very convenient but how can I remove anchor part from an url? For example:

My base url:

While using application I move to a place that adds new history item.

In code:


As result:

I change place one more time:

In code:


As result:

Then I want to go back to my home page (

What should be placed in code?:


to get back to:

Is there any standart way I can achieve my goal?

If I add something like this:




the url will become

And this is not what I am lloking for, I need it without sharp character.


If you use History.newItem(null); a new event will be fired. As a result, you will toggle your home page :

Having or not a # at the end is the same thing, am I wrong ?


  // Get the last part of the url and remove #token
  String s = Location.getHref().substring(Location.getHref().lastIndexOf("/"));
  s = s.substring(0, s.indexOf("#")-1);

  protected native void setToken(String token) /*-{
    $wnd.history.pushState({},'', token);