location.href的基本用法
问题
js中的location.href的作用是什么?有几种用法?区别是什么?
作用
主要用于跳转页面
用法与区别
1.self.location.href=“url”; //1.仅在本页面打开url
2.window.location.href=“url”; //2.当前页面打开URL页面
3.this.location.href=“url”; //3.用法和self.location.href一直
4.location.href=“url”; //4.当前页面打开URL页面
5.parent.location.href=“url”; //5.在父窗口打开此url窗口
6.top.location.href=“url”; //6.在顶层页面打开url(跳出框架)