Do we have multiple (different) global objects in a multi-frame frameset HTML?
It's common to use:
if(window.top != window.self) {
alert("We're in a frame");
}
where window
is a property of the [[global]]
object like self
is, and both are references to [[global]]
object itself. But, if window.top
refers to the topmost window
frame object and therefore to the [[global]]
object, how many [[global]]
objects do we have? Or maybe the window DOM part is changed only?
Each document
(therefore each frame) has its own window
object.
The window
object is not a unique singleton. It's just an instance of Window
. One is created for each document
, and can be accessed through document.defaultView
.
If and only if two pieces of your application share a document
, they share a window
.
There is no [[global]]
object: global scope is just a way of conveniently accessing the current window
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With