- js重定向
1.window.location.href="index.html"; //当前页面打开(window对象的属性都可以省略)
2.parent.location.href="/url"; //在父页面打开新页面;
3.top.location.href="/url"; //在顶层页面打开新页面;(href可以省略)
/*top属性返回最顶层的先辈窗口。
如果窗口本身就是一个顶级窗口,top属性存放对窗口自身的引用。
如果窗口是一个框架,那么top属性引用包含框架的顶层窗口。*/
4.window.location.replace("http://www.labangme.com");
/*替换当前页面replace()方法不会在 History 对象中生成一个新的记录。
新的url将覆盖history对象中的当前记录。*/
5.window.history.back(); //返回历史列表中的前一个 URL
6.history.go(-1); //同上;
7.window.history.forward(); //加载历史列表中的下一个 URL
8.history.go(1); //同上;
9.history.go(number|URL); //go()方法也可以加载一个具体地址
10.window.location.href=document.referrer; //返回前一个页面并刷新这个页面
-window.location.hash
window.location.hash; //得到的是锚链接。相比如href,
通过window.location.hash并不会跳转到新的链接,只会在当前链接里面改变锚链。
/*并且如果有<a href="#book">通过window.location.hash得不到完整的链接(URL),仅仅得到#book.*/