【问题标题】:js setting default url after using history.pushstatejs 使用 history.pushstate 后设置默认 url
【发布时间】:2012-02-21 07:43:33
【问题描述】:

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

site.com

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

site.com/site/subsite

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

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

document.location.pathname 是“site.com/site/subsite”

然后我回到起点:(

【问题讨论】:

    标签: javascript url history


    【解决方案1】:
    history.pushState("", document.title, "/");
    

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

    【讨论】:

      猜你喜欢
      • 2014-12-06
      • 1970-01-01
      • 2020-12-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多