Reputation: 105517
I just incidentally forgot to remove console.log(parent)
in my experiment and it logged Window
. I didn't know there's the global variable parent
. Where is it defined? I'm using latest Chrome.
Upvotes: 1
Views: 264
Reputation: 1074959
It's defined in the HTML specification, specifically here:
The parent IDL attribute, on getting, must run the following algorithm:
Let windowProxy be this Window object's
WindowProxy
object.If there is no browsing context with windowProxy as its
WindowProxy
object, then return null.Let context be that browsing context.
If context is a child browsing context of another browsing context parent, then return parent's
WindowProxy
object.Otherwise, context must be a top-level browsing context. Return context's
WindowProxy
object.
See also MDN.
Basically, parent
is the window's parent (e.g., it's a frame or iframe), if it has one, or the window itself if it doesn't.
There's also the related, but different, opener
(MDN | spec).
Upvotes: 1