5. History: 历史记录对象
1. 创建(获取):
1. window.history
2. history
2. 方法:
* back(): 加载history列表中的前一个 URL。
* forward(): 加载history列表中的下一个 URL。
* go(): 加载history列表中的某个具体页面。
3. 属性:
* length: 返回当前窗口历史列表中的 URL 数量。
<!--History对象-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>History对象</title>
</head>
<body>
<input type="button" id="btn" name="获取历史记录个数">
<a href="09_History.html">09页面</a>
<input type="button" id="forward" name="前进">
<script type="text/javascript">
// 1.获取按钮
var btn = document.getElementById("btn");
// 2.绑定单机事件
btn.onclick = function(){
// 3.获取当前窗口历史记录个数
var length = history.length;
alert(length);
}
// 1.获取按钮
var btn = document.getElementById("forward");
// 2.绑定单机事件
forward.onclick = function(){
// 3.前进
history.forward();
}
</script>
</body>
</html>
History对象
最新推荐文章于 2023-02-09 17:44:15 发布