zoukankan      html  css  js  c++  java
  • JavaScrip--history对象

    History对象
    history实际上是javascript的对象,不是HTML DOM对象
    我们主要讲解它的一个属性
    length---返回浏览器历史列表中的 URL 数量
    三个方法
    back()----加载history列表中上一个页面
    forward()----加载history列表中下一个页面
    go()----加载history列表中一个具体的页面

    例子:
    <body>
    <a href="historyObject.html">前进到history对象页面</a>
    <button onclick="goForward()">前进</button>
    <button onclick="listHistory()">浏览历史</button>
    <p id="pid" style="display: inline;"></p>
    <script>
        function goForward(){
            history.forward();
        }
        function listHistory(){
            var p=document.getElementById("pid");
            p.innerHTML="浏览历史为:"+history.length;
        }
    </script>
    </body>

    historyObject.html页面:
    <body>
    <button onclick="goBack()">返回</button>
    <script>
        function goBack(){
            history.back();
        }
    </script>
    </body>

  • 相关阅读:
    北方联动科技论坛上的回答
    Fire Net
    The shortest problem(hdu,多校
    Air Raid
    过山车
    Courses
    Network
    Common Subsequence
    The mook jong
    Distribution money
  • 原文地址:https://www.cnblogs.com/YangMT/p/4865810.html
Copyright © 2011-2022 走看看