本文主要介绍了window.history对象使用方法
window.history对象在编写时可不使用 window 这个前缀。为了保护用户隐私,对 JavaScript 访问该对象的方法做出了限制。 方法: history.back() - 加载历史列表中的前一个URL,这与在浏览器中点击前进按钮是相同的 history.forward() - 加载历史列表中的下一个URL,这与在浏览器中点击前进按钮是相同的 实例: 代码如下: <html> <button name="back" value="后退" onclick="goBack()">后退</button> <button name="forward" value="前进" onclick="goForward()">前进</button> <script type="text/javascript"> function goBack(){ history.back(); } function goForward(){ history.forward(); } </script> </html> 其他方法: 代码如下: history.go(0);//刷新当前页面 //以下是要在浏览器中有历史记录的,否则不会有效果. history.go(1);//前进一页 history.go(-1);//后退一页 history.go(-2);//后退两页 history.length;//当前窗口包含的历史记录条数