History 对象的方法
| 方法 | 描述 | IE | F | O |
|---|---|---|---|---|
| back() | 加载 history 列表中的前一个 URL | 4 | 1 | 9 |
| forward() | 加载 history 列表中的下一个 URL | 4 | 1 | 9 |
| go() | 加载 history 列表中的某个具体页面 | 4 | 1 | 9 |
示例代码
Demo10
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<head>
<title>Title</title>
<script type="text/javascript">
function goForward() {
history.forward();
}
</script>
</head>
<body>
<a href="Demo11.html">Demo11</a>
<input type="button" value="前进" onclick="goForward()"/>
</body>
</html>
Demo11
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<head>
<title>Title</title>
<script type="text/javascript">
function goBack(){
history.back();
}
</script>
</head>
<body>
青花瓷~ <input type="button" value="后退" onclick="goBack()"/>
</body>
</html>
本文介绍了浏览器History对象的三个核心方法:back(), forward() 和 go() 的使用方式,并通过示例代码展示了如何在网页中实现前进和后退的功能。
1594

被折叠的 条评论
为什么被折叠?



