zoukankan      html  css  js  c++  java
  • JavaScript Window History 浏览器的历史

    window.history 对象在编写时可不使用 window 这个前缀。

    为了保护用户隐私,对 JavaScript 访问该对象的方法做出了限制。

    一些方法:

    • history.back() - 与在浏览器点击后退按钮相同
    • history.forward() - 与在浏览器中点击按钮向前相同

    Window History Back

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

    这与在浏览器中点击后退按钮是相同的

    Window History Forward

    history forward() 方法加载历史列表中的下一个 URL。

    这与在浏览器中点击前进按钮是相同的

    Window History Forward

    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;//当前窗口包含的历史记录条数
  • 相关阅读:
    MySQL8.0 不能使用group by解决方法
    xtrabackup备份恢复
    pycharm使用
    CMDB开发(三)
    Restful接口规范
    django-rest-framework框架(一)
    CMDB开发(二)
    CMDB开发(一)
    数据可视化之matplotlib模块
    数据分析之pyecharts v1版本
  • 原文地址:https://www.cnblogs.com/amosli/p/3475973.html
Copyright © 2011-2022 走看看