4.history对象.js 352 B

1234567891011
  1. var btn = document.getElementById("btn");
  2. btn.onclick = function() {
  3. history.back();
  4. // history.back() 返回history上一个url
  5. }
  6. var btn1 = document.getElementById("btn1");
  7. btn1.onclick = function() {
  8. history.forward();
  9. // history.forward() 进入history下一个url
  10. }
  11. // history.go(num) 想跳转哪个页面 就填对应层级数字