Reputation: 6871
I've been reading the great Eloquent JavaScript and came across this:
window.window === window // true
window.top === window // true
window.top === window.top.top.top.window //true
This is all expected since the object is pointing to itself. And I also understand window holds all of the global JavaScript variables including itself but:
window.top
?Upvotes: 0
Views: 66
Reputation: 13726
top
window.top
refers to the top-most window from a window nested in one or more layers of <iframe>
sub-windows
self (or window)
From the MDCN page for window.self
:
if (window.parent.frames[0] != window.self) {
// this window is not the first frame in the list
}
window.self is almost always used in comparisons like in the example above, which finds out if the current window is the first subframe in the parent frameset.
Upvotes: 2