0
点赞
收藏
分享

微信扫一扫

JavaScript 69 JavaScript Web API 69.3 Web History API

Spinach菠菜 2022-11-15 阅读 52

JavaScript

文章目录

69 JavaScript Web API

69.3 Web History API

Web History API 提供了访问 windows.history 对象的简单方法。

window.history 对象包含用户访问过的 URL(网站)。

所有浏览器都支持 Web History API:

在这里插入图片描述

69.3.1 History back() 方法

back() 方法加载 windows.history 列表中的前一个 URL。

【举个栗子】

<button onclick="myFunction()">后退</button>

<script>
function myFunction() {
  window.history.back();
}
</script>
69.3.2 History go() 方法

go() 方法从历史列表中加载一个特定的 URL:

<button onclick="myFunction()">后退两页</button>

<script>
function myFunction() {
  window.history.go(-2); //后退两页
}
</script>
69.3.3 History 对象属性

在这里插入图片描述

69.3.4 History 对象方法

在这里插入图片描述

举报

相关推荐

0 条评论