window.opener
refers to the window that calledwindow.open( ... )
to open the window from which it’s calledwindow.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
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.)