I'm trying to understand a hierarchical picture of window
, document
and iframe
.
So, window
is simply the browser's window and document
is where the DOM exists. The document
is loaded in window
.
Is creating an iframe
much like creating a dialog (window.openDialog()
) (which is nothing but a window)?
Both have a content document and parent window.
An <iframe> tag hosts a separate embedded window, with its own separate document and window objects. We can access them using properties: iframe.
In short, to check if a page is in an iframe, you need to compare the object's location with the window object's parent location. If they are equal, then the page is not in an iframe; otherwise, a page is in an iframe.
Yes you can open a new Window from iFrame........
iFrames are an HTML tag and have been around for absolutely ages having been introduced back in 1997. Despite their age, they are still commonly used and are supported by all modern browsers.
Here's a very good discussion from WHATWG, the founders of HTML5: 6 Loading Web pages -- HTML: The Living Standard - Edition for Web Developers
In summary, but lots more at the actual page:
A browsing context is an environment in which Document objects are presented to the user.
A tab or window in a Web browser typically contains a browsing context, as does an iframe.
and
Certain elements (for example, iframe elements) can instantiate further browsing contexts. These are called nested browsing contexts.
And, if you want to know more about WHATWG: FAQ - WHATWG Wiki
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