页面常用跳转

1.定时跳转或者原地刷新
HTML5页面跳转的几种方法
优点:简单
缺点:Struts Tiles中无法使用
对于刷新当前页面js控制为:
window.location.reload(); //刷新当前页面,重新向服务器请求数据
2.js手动跳转
HTML5页面跳转的几种方法
优点:灵活,可以结合更多的其他功能
缺点:受到不同浏览器的影响
上面的方法跳转会保留历史页面记录,通过返回键可以返回上一个界面,如果不像返回,直接替换页面永续i安眠的函数:
window.location.replace("hello.html"); //刷新当前页面,重新向服务器请求数据
3.历史记录跳转
1. window.history.go():
window.history.go(-1); // 返回上一页
window.history.go(-2); // 返回上两页
window.history.go("hello.html"); // 跳转到hello.html
2. window.history.back();等同于:window.history.go(-1); //返回上一页
3. window.history.forward(); // 返回下一页

猜你喜欢

转载自blog.csdn.net/weixin_41049850/article/details/80868735