history api

在js中存在一个history接口,其允许我们对浏览器访问历史进行操作

属性

history.length   只读属性,返回历史记录中元素的数目

方法

  • histoty.go()             跳转到相对于当前访问历史的位置,为正数时,参数为历史记录中排在当前记录之后的某条记录;为负数时,参数为历史记录中排在当前记录之前的某条记录。
  • history.back()         返回上一条历史记录,相当于history.go(-1)
  • history.forward()     进入到下一条历史记录,相当于history.go(1)
  • history.pushState()         向历史记录中的末尾添加某条记录
  • history.replaceState()     更新历史记录上最新记录

 

posted @ 2020-04-19 17:02  ashen1999  阅读(174)  评论(0编辑  收藏  举报