js实现页面跳转的几种方式

1. window.location.href

  • 直接跳转无参数
window.location.href = "test.html";
  • 跳转有参数
window.location.href = "test.jsp?id=" + testId;

2. 返回上一层

  • window.history.back(-1)

        直接返回当前页的上一页,数据全部消失,是个新页面;

  • window.history.go(-1)

        返回当前页的上一页,不过表单里的数据全部还在;

  • window.history.go(1) // 前进
  • window.history.back() // 后退+刷新

3. window.navigate

window.navigate = "test.jsp"

 4.  self.location

self.location="test.html";

5. top.location

top.location="test.jsp";

6. window.open

window.open = "test.html";


版权声明:本文为qq_43654065原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。