何时使用window.opener / window.parent / window.top [英] When to use window.opener / window.parent / window.top

查看:135
本文介绍了何时使用window.opener / window.parent / window.top的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在JavaScript中何时使用 window.opener / window.parent / 窗口。顶部

In JavaScript when to use window.opener / window.parent / window.top ?

推荐答案


  • window.opener 指的是调用 window.open(...)的窗口,打开名为

  • 的窗口
  • window.parent 指的是< frame> 或<$ c $中窗口的父级c>< iframe>

  • window.top 是指窗口中最顶层的窗口嵌套在< iframe> 子窗口的一个或多个图层中

    • window.opener refers to the window that called window.open( ... ) to open the window from which it's called
    • window.parent refers to the parent of a window in a <frame> or <iframe>
    • window.top refers to the top-most window from a window nested in one or more layers of <iframe> sub-windows
    • 当它们与引用窗口的情况无关时,它们将是 null (或者可能是 undefined )。 (引用窗口表示运行JavaScript代码的上下文窗口。)

      Those will be null (or maybe undefined) when they're not relevant to the referring window's situation. ("Referring window" means the window in whose context the JavaScript code is run.)

      这篇关于何时使用window.opener / window.parent / window.top的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆