通过JavaScript删除锚点,但不删除参数

pyv*_*yvi 1 javascript regex url

我想更改以下示例网址

http://www.mydomain.net/site?argument1=test1&argument2=test2#anchor
Run Code Online (Sandbox Code Playgroud)

http://www.mydomain.net/site?argument1=test1&argument2=test2
Run Code Online (Sandbox Code Playgroud)

用JavaScript.我最好怎么做?

编辑:使用'锚'和其他文本元素,我的意思是通用元素.所以锚也可以是另一个文本.抱歉.

Que*_*ith 5

如果您尝试更改当前位置的锚点,最好更改window.location.hash:

window.location.hash = '';
Run Code Online (Sandbox Code Playgroud)

在某些浏览器中,这将避免在URL更改时重新加载页面.