网站首页 > 知识剖析 正文
window.history 对象包含浏览器的历史。
Window History
window.history对象在编写时可不使用 window 这个前缀。
为了保护用户隐私,对 JavaScript 访问该对象的方法做出了限制。
一些方法:
history.back() - 与在浏览器点击后退按钮相同
history.forward() - 与在浏览器中点击按钮向前相同
Window History Back
history.back() 方法加载历史列表中的前一个 URL。
这与在浏览器中点击后退按钮是相同的:
实例
在页面上创建后退按钮:
<html>
<head>
<script>
function goBack()
{
window.history.back()
}
</script>
</head>
<body>
<input type="button" value="Back" onclick="goBack()">
</body>
</html>
以上代码输出为:
Window History Forward
history forward() 方法加载历史列表中的下一个 URL。
这与在浏览器中点击前进按钮是相同的:
实例
在页面上创建一个向前的按钮:
<html>
<head>
<script>
function goForward()
{
window.history.forward()
}
</script>
</head>
<body>
<input type="button" value="Forward" onclick="goForward()">
</body>
</html>
以上代码输出为:
如您还有不明白的可以在下面与我留言或是与我探讨QQ群308855039,我们一起飞!
猜你喜欢
- 2024-12-23 轻量级开源wiki系统介绍 轻量开源论坛
- 2024-12-23 为了强推Edge浏览器,微软在Win11搞起了小动作
- 2024-12-23 分享windows好用的几个插件 w10插件
- 2024-12-23 windows浅尝NW.js windows浅色主题壁纸
- 2024-12-23 windows系统如何搭建网站? windows2016搭建网站
- 2024-12-23 推荐50个超实用的 Chrome 扩展,建议收藏
- 2024-12-23 使用JS打印当前HTML页面的几个细节
- 2024-12-23 Mozilla找到了让Firefox成为Windows 11默认浏览器的新方法
- 2024-12-23 HTML 也能开发桌面软件之 NW.js 中的 App 应用程序类
- 2024-12-23 把HTML网页下载为单文件,可离线访问
- 最近发表
- 标签列表
-
- xml (46)
- css animation (57)
- array_slice (60)
- htmlspecialchars (54)
- position: absolute (54)
- datediff函数 (47)
- array_pop (49)
- jsmap (52)
- toggleclass (43)
- console.time (63)
- .sql (41)
- ahref (40)
- js json.parse (59)
- html复选框 (60)
- css 透明 (44)
- css 颜色 (47)
- php replace (41)
- css nth-child (48)
- min-height (40)
- xml schema (44)
- css 最后一个元素 (46)
- location.origin (44)
- table border (49)
- html tr (40)
- video controls (49)