history.back():回到历史记录的上一步

eg:两个网页来回跳转

Video_2020-11-24_162510.wmv (89.29KB)

Code:

  1. <!-- 02.html -->
  2. <body>
  3. <p>02</p>
  4. <a href="html/03.html">03.html</a>
  5. </body>
  1. <!-- 03.html -->
  2. <body>
  3. <p>03</p>
  4. <button id="btn">btn</button>
  5. <script>
  6. var btn = document.getElementById("btn");
  7. btn.onclick=function(){
  8. history.back();
  9. }
  10. </script>
  11. </body>