js在使用history.pushstate后设置默认URL

use*_*557 4 javascript url history

我有个问题.如何从history.pushState添加的网址"内容"中删除?例如,我有一个这个网址:

site.com
Run Code Online (Sandbox Code Playgroud)

好的,现在我将此网址更新为:

site.com/site/subsite
Run Code Online (Sandbox Code Playgroud)

我如何恢复默认网址(site.com).

我试试,history.pushState("",document.title,document.location.pathname)但是,

document.location.pathname 是"site.com/site/subsite"

然后我回到起点:(

Nik*_*iko 5

history.pushState("", document.title, "/");
Run Code Online (Sandbox Code Playgroud)

它将完全从域url中删除状态.