JS BOM history子对象

  1. 属性: length
  2. 方法: back() forward() go(1)

    <a href="h_1.html">h_1</a>
    <a href="h_2.html">h_2</a>
    <a href="h_3.html">h_3</a>
    <button id="f">前进</button>
    <button id="b">后退</button>
    <script type="text/javascript">
     var f = document.getElementById('f');
     var b = document.getElementById('b');
    
     b.onclick = function() {
         window.history.back();//这个位置window是可以省略的 with
         window.history.go(-2);
     }
    
     f.onclick = function() {
         window.history.forward();
         window.histroy.go(1);
     }
    </script>