zoukankan      html  css  js  c++  java
  • History 对象

    History 对象
    History 对象包含用户(在浏览器窗口中)访问过的URL;
    History 对象是window 对象的一部分,可用过window.history属性对其进行访问;
    没有应用于History对象的公开标准,不是所有浏览器都支持该对象
    History 对象属性
    length //返回历史列表中的网址数
    History对象方法
    back() 加载history列表中的前一个URL
    foward() 加载history 列表中的下一个URL
    go() 加载history列表中的某个具体页面

    History back()方法
    定义和用法
    back方法可以加载历史列表中 的前一个URL(如果存在);
    调用该方法的效果等价于点击后退按钮或调用history.go(-1)

    History forward()方法
    定义和用法
    foward() 方法可加载历史列表中的下一个URL
    调用该方法的效果等价于点击前进按钮或调用history.go(1);
    history.forward()

    History go()方法
    定义和用法
    go()方法可加载历史列表中的某个具体页面;
    该参数可以是数字,使用的是要访问的URL 在History 的URL 列表中的相应位置(-1 上一个页面,1前进一个页面)
    或一个字符串,字符串必须是局部或完整的URL,该函数会去匹配字符串的第一个URL
    语法
    history.go(number|URL)

    eg:
    //-----------------------------------------------------------------
    index1.html
    <a href="index2.html">跳转到页面2</a>
    //-----------------------------------------------------------------
    index2.html
    <input type="button" value="返回" onclick="goBack()" />
    <br/>
    <a href="index3.html" >页面2 跳转到 页面3</a>
    <br/>
    <input type="button" value="前进" onclick="goForward()" />
    function goBack(){
    //window.history.back();
    window.history.go(-1);
    }
    function goForward(){
    window.history.forward()
    }
    //-----------------------------------------------------------------
    index3.html
    <input type="button" value="返回页面2" onclick="goBack()" />
    <input type="button" value="返回页面1" onclick="goBack2()" />
    
    
    function goBack(){
    window.history.back();
    //window.history.go(-1);
    }

    function goBack2(){
    window.history.go(-2);
    }











  • 相关阅读:
    Problem C: 时间类的常量
    Problem B: 时间类的错误数据处理
    Problem A: 时间类的拷贝和整体读写
    Problem B: 平面上的点——Point类 (IV)
    Problem C: 平面上的点——Point类 (V)
    Problem A: 平面上的点——Point类 (III)
    中间的数(若已经排好序)
    软件工程概论团队结组
    软件工程个人作业04 子数组循环数组
    软件工程个人作业03
  • 原文地址:https://www.cnblogs.com/nnf-888/p/9023288.html
Copyright © 2011-2022 走看看