JS-BOM编程之history对象

本文介绍了HTML浏览器对象模型(BOM)中的History对象及其方法,包括如何使用back()、forward()和go()方法实现页面前进和后退的功能。

History 对象包含用户(在浏览器窗口中)访问过的 URL。

History 对象是 window 对象的一部分,可通过 window.history 属性对其进行访问。

注释:没有应用于 History 对象的公开标准,不过所有浏览器都支持该对象。

history对象代表浏览器窗口上的前进和后退按钮

History 对象最初设计来表示窗口的浏览历史。但出于隐私方面的原因,History 对象不再允许脚本访问已经访问过的实际 URL。唯一保持使用的功能只有 back()forward()go() 方法。

back()加载 history 列表中的前一个 URL。
forward()加载 history 列表中的下一个 URL。
go()

加载 history 列表中的某个具体页面。

 

 1 <!doctype html>
 2 <html lang="en">
 3  <head>
 4   <meta charset="UTF-8">
 5   <meta name="Generator" content="EditPlus®">
 6   <meta name="Author" content="">
 7   <meta name="Keywords" content="">
 8   <meta name="Description" content="">
 9   <title>BOM编程之history对象</title>
10  </head>
11  <body>
12   <!--history对象代表浏览器窗口上的前进和后退按钮-->
13     <a href="34.BOM编程之history对象的链接对象.html">34</a>
14     <input type="button" value="前进" onclick="window.history.go(1)"/>
15  </body>
16 </html>
 1 <!doctype html>
 2 <html lang="en">
 3  <head>
 4   <meta charset="UTF-8">
 5   <meta name="Generator" content="EditPlus®">
 6   <meta name="Author" content="">
 7   <meta name="Keywords" content="">
 8   <meta name="Description" content="">
 9   <title>BOM编程之history对象的链接对象</title>
10  </head>
11  <body>
12     <input type="button" value="后退" onclick="window.history.back()"/>
13     <input type="button" value="前进" onclick="window.history.go(-1)"/>
14     <input type="button" value="前进" onclick="window.history.go(1)"/>
15   
16  </body>
17 </html>

 

转载于:https://www.cnblogs.com/xiuxiu123456/p/8521003.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值