JavaScript----history对象

版权声明:一心不安 https://blog.csdn.net/qq_42700595/article/details/83444153

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <script language="JavaScript">
       function loading(){
           var output = document.getElementById("output");
           output.value= history.length;
       }
       /**
        * back 向前一个历史页面
        * forward  向后一个历史页面
        * go(参数值) 根据参数值跳转至指定历史页面
        * @param mothod
        */
       function historyTest(mothod) {
           if(mothod=='back'){
               history.back();
               return;
           }
           if(mothod=='forward'){
               history.forward();
               return;
           }
           if(mothod=='go'){
               history.go();
               return;
           }
       }
    </script>
</head>
<body onload="loading()">
    <input type="text" id="output" />
    <input type="button" value="back" onclick="historyTest('back')"/>
    <input type="button" value="forward" onclick="historyTest('forward')"/>
    <input type="button" value="go" onclick="historyTest('go')"/>

</body>
</html>

猜你喜欢

转载自blog.csdn.net/qq_42700595/article/details/83444153