`
jafisher
  • 浏览: 55583 次
  • 性别: Icon_minigender_1
  • 来自: 长沙
社区版块
存档分类
最新评论

页面跳转方式

 
阅读更多
web前端开发中,经常使用到页面跳转,下面是使用过的几种常用的跳转方式。

1.html跳转,通过<a>标签,
<a href="www.xxx.com" target="_self">链接</a>

,其中target共有4种模式:
1)_self,默认方式,在当前窗口跳转
2)_blank,跳转到新窗口
3)_parent,在当前父窗口跳转
4)_top,在当前顶级窗口跳转

2.js跳转,js跳转能控制的属性要比html直接跳转要更多。
window.location.href = "www.xxx.com";

location其实还有N种属性,可以控制页面的位置等信息,但这种方式好像没法跳转到新页面上。
window.open('www.xxx.com', '_self');

第二个参数和html跳转中的target模式一样,也是有4种方式,同时,open函数也带有N种属性。

3.此外,js中还可以记录页面跳转的历史,通过历史访问顺序来控制:
window.history.back();
window.history.go();
window.history.forward();
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics