java – GWT. Delete anchor part URL

Hi, I'm using GWT and its standard way to support history through the history course It's very convenient, but how to remove the anchor part from the web address? For example:

My basic website:

http://www.mysuperwebsite.com/myapp

When I use the application, I move to the location where I add a new history item

In the code:

History.newItem("funnygame");

result:

http://www.mysuperwebsite.com/myapp#funnygame

I'll change the place again:

In the code:

History.newItem("notsofunnygames");

result:

http://www.mysuperwebsite.com/myapp#notsofunnygames

Then I want to go back to my home page( http://www.mysuperwebsite.com/myapp ).

What should be in the code?:

????

go back to:

http://www.mysuperwebsite.com/myapp

Is there a standard way to achieve my goal?

If I add something like this:

History.newItem("");

or

History.newItem(null);

The website will become

http://www.mysuperwebsite.com/myapp#

This is not what I like. I need it to have no sharp character

Solution

If you use history newItem(null); A new event will be triggered

In the end, is # it the same thing? Am I wrong?

Edit:

...
  // 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);
  setToken(s);
  ...

  protected native void setToken(String token) /*-{
    $wnd.history.pushState({},'',token);
}-*/;
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>