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);
    }











  • 相关阅读:
    初认识AngularJS
    (imcomplete) UVa 10127 Ones
    UVa 10061 How many zero's and how many digits?
    UVa 11728 Alternate Task
    UVa 11490 Just Another Problem
    UVa 10673 Play with Floor and Ceil
    JSON对象和字符串的收发(JS客户端用typeof()进行判断非常重要)
    HTML.ActionLink 和 Url.Action 的区别
    EASYUI TREE得到当前节点数据的GETDATA方法
    jqueery easyui tree把已选中的节点数据拼成json或者数组(非常重要)
  • 原文地址:https://www.cnblogs.com/nnf-888/p/9023288.html
Copyright © 2011-2022 走看看