javascript 实现页面跳转 然后按返回键不会回到上一页

<!doctype html>

<html lang="en">

 <head>

  <meta charset="UTF-8">

  <meta name="Generator" content="EditPlus®">

  <meta name="Author" content="">

  <meta name="Keywords" content="">

  <meta name="Description" content="">

  <title>Document</title>

  <script type="text/javaScript">

    function f() {

        alert(history.length);

        location.replace('http://www.baidu.com');

        alert(history.length);

    }

  </script>

 </head>

 <body>

    这个是一个页面

    <button type="button" onclick="f()">点击我跳转新的页面</button>

 </body>

</html>

我不确定这个是不是你要的! 知识利用了replace这个方法将历史栈中的页面替换了。我理解你的提出的问题“回不到上一页” 我就当是那个页面再也找不到了。

猜你喜欢

转载自blog.csdn.net/qq_34627002/article/details/82731876