JS-BOM编程之history对象

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>

 

posted @ 2018-03-07 10:42  不上进的小猫  阅读(191)  评论(0编辑  收藏  举报