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>

猜你喜欢

转载自www.cnblogs.com/startl/p/12244267.html