问题:如果直接在嵌套页面里面使用window.location.href='http://www.xxx.xx',会发现页面无法跳转,甚至出现跨域问题
解决:通过window.top.location.href 或者 window.parent.location.href 跳转
两者区别如下:
-
window.parent.location
用于更改父窗口的位置。 -
window.top.location
-
它是对象'window'的属性。
-
它返回窗口层次结构中最顶层窗口的位置。
-
如果窗口没有父窗口,则top是对自身的引用(窗口=== window.top)
-