js操作history

js操作history

  1. pushState

    pushState只会在当前history中添加一条记录,并不会刷新浏览器
    history.pushState({}, "my title", "/test.html")
    
  2. replaceState

    replaceState会替换当前的history中的记录,并且刷新浏览器
    history.replaceState({}, "my title", "/test.html")
    
  3. 跳转

    history.go(1)   前进一个页面
    history.go(-1)  后退一个页面
    
  4. navigator

    获取用户浏览器相关信息
    console.log(navigator)
    
原文地址:https://www.cnblogs.com/ye-hcj/p/10351783.html