In JavaScript, what are window.opener
, window.parent
, and window.top
, and when can I use them?
window.opener
refers to the window that called window.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-windowsThose 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.)