当前位置:首页 > Windows程序 > 正文

js基础之Window History(BOM)

2024-03-31 Windows程序

window.history 对象包含浏览器历史。
window.history 对象可不带 window 书写。

为了保护用户的隐私,JavaScript 访问此对象存在限制。

一些方法:

history.back() - 等同于在浏览器点击后退按钮

history.forward() - 等同于在浏览器中点击前进按钮

history.back() 方法加载历史列表中前一个 URL。

这等同于在浏览器中点击后退按钮。

<html> <head> <script> function goBack() { window.history.back() } </script> </head> <body> <input type="button" value="Back" onclick="goBack()"> </body> </html> history forward() 方法加载历史列表中下一个 URL。

这等同于在浏览器中点击前进按钮。

<html> <head> <script> function goForward() { window.history.forward() } </script> </head> <body> <input type="button" value="Forward" onclick="goForward()"> </body> </html>

js基础之Window History(BOM)

标签:

原文地址:https://www.cnblogs.com/jessie-xian/p/11596006.html

温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/9127.html

Jm-杰米博客Jamie
草根站长的技术交流乐园!IT不会不要紧快来好好学习吧!
  • 20786文章总数
  • 7494585访问次数
  • 建站天数
  • 友情链接