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>
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/161553.html
標籤:JavaScript
上一篇:BOM物件——Navigator
下一篇:BOM物件——Location
