BOM的history对象

Posted startl

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了BOM的history对象相关的知识,希望对你有一定的参考价值。

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>history对象</title>
</head>
<body>
<input type="button" value="front" onclick="f1()">
<a href="history_obj1.html">555</a>
<script>
//history内部有三个方法:forward,back,go 一个属性 length
function f1() {
// history.forward();
history.go(1);//history.go(0)代表当前页面
}


</script>

</body>
</html>
======================================================================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Title</title>
</head>
<body>
<input type="button" value="back" onclick="f2()">
<script>
function f2() {
// history.back();
history.go(-1);
alert(history.length);// 2 返回历史URL个数

}


</script>

</body>
</html>

以上是关于BOM的history对象的主要内容,如果未能解决你的问题,请参考以下文章

BOM-History历史记录对象

BOM之history对象

JS笔记 BOM之History(操作页面向前向后翻)

BOM之history对象(转)

BOM 浏览器对象模型_当前窗口的浏览历史 history 对象

js基础之Window History(BOM)