了解window.top

 

 当B嵌套在A页面中时,直接是不能调用A页面的方法和属性的

如果想使用A页面中的方法和属性 可以使用window.top (返回窗口层级最顶层窗口的引用)

if(window.top != window.self) {
  window.top.location.href = window.location.href;
window.top.oepn = window.open }

 

当在iframe内时, 直接window.location.href 会打开iframe内的网站,  要解决这个问题 使用window.top.location.href = xxx 或者 window.top.open('xxx')

 

posted @ 2020-10-30 17:42  一路向北√  阅读(1215)  评论(0编辑  收藏  举报

web应用开发&研究 -

业精于勤而荒于嬉。

工作,使我快乐。


Font Awesome | Respond.js | Bootstrap中文网