BOM对象——History
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script type="text/javascript">
/*
History
- 对象能够用来操做浏览器向前或者向后翻页
*/
window.onload = function() {
var btn = document.getElementsByTagName("button")[0];
console.log(btn);
btn.onclick = function() {
// History.length 返回当前访问连接的数量
// alert(history.length)
/*
back()
- 能够用来回退到上一个页面,做用和浏览器的回退按钮同样
*/
// history.back();
/*
forward()
- 能够 前进到下一个页面,做用和浏览器的前进按钮同样
*/
// history.forward();
/*
go()
- 能够用来跳转到指定的页面
- 须要一个整数做为参数
1.表示向前跳转一个页面
2.表示向前跳转两个页面
-1.表示向后跳转一个页面
-2.表示向后跳转两个页面
*/
// histor.go();
}
};
</script>
</head>
<body>
<button type="button" id="btn">history</button>
<h1>History</h1>
</body>
</html>