Multiple global objects in multiple HTML frames?

Do we have several (different) global objects in HTML format with multiple frames?

Commonly used:

if(window.top != window.self) { alert("We're in a frame"); } 

where window is a property of the [[global]] object, for example self is, and both are references to the [[global]] object itself. But if window.top refers to the window.top object of the window frame and, therefore, to the [[global]] object, how many [[global]] objects do we have? Or perhaps only part of the DOM window is changed?

+5
source share
1 answer

Each document (therefore, each frame) has its own window object.

The window object is not a unique singleton. This is just an instance of window . One is created for each document , and can be accessed through document.defaultView .

If and only if two parts of your application share document , they share the window .

There is no object [[global]] : the global area is just a way to conveniently access the current window .

0
source

Source: https://habr.com/ru/post/1200151/


All Articles