子框架将打开一个弹出窗口.如何检查该弹出窗口是否从父级打开

Child frame opens a popup. How do I check if that popup is opened from the parent?

本文关键字:窗口 是否 检查 何检查 将打开 一个 框架      更新时间:2023-09-26

我有一个页面包含一个框架。从这个框架内,我可以打开一个弹出窗口。如何判断此弹出窗口是否从父页面打开?

if (window.opener && 
    window.opener.top === window.opener) {
    // this window was opened from a window that is it's own top (not an IFrame)
}