How to remove query string from url using javascri

2019-09-18 11:19发布

I have one page when which have a query string like http://www.test.com/mypage?abc=xyz

I want only page URL after loading in browser, but my query string will not be removed. e.g. http://www.test.com/mypage.

I need query string each and every time. I don't want to visualize to user.

2条回答
ゆ 、 Hurt°
2楼-- · 2019-09-18 11:50

Eventually you still need to send the request with those query string, so I assume you are asking to hide it in the address bar. I suggest go with create a big 100% height/width iframe to link to your detail page and then user will not able to see the query string in the address bar directly as it's in the iframe

查看更多
神经病院院长
3楼-- · 2019-09-18 11:52

The only way to do it is with a new HTML 5 feature on the history object:

window.history.replaceState(“Replace”, “Page Title”, “/mypage”);

Otherwise you'll need to use POST or reload the page with cookies to hide the query parameters.

查看更多
登录 后发表回答