This article is a mirror article of machine translation, please click here to jump to the original article.

View: 5840|Reply: 3

[JavaScript] JS determines whether the current page is an iframe or a popup window

[Copy link]
Posted on 7/30/2022 10:27:58 AM | | | |
window

When applying a page with a frameset or iframe, there are several window concepts

window.self: is a reference to the current window itself. Equivalent to window and window.self
window.parent: Returns to the parent window.
window.top: Return to the top-level parent window (some windows have several layers of framesets or iframes)

JS determines if the current page is an Iframe window

When the current page does not have a parent window, both window.parent and window.top return a reference to the current window.
You can tell if the current page is in an iframe by telling if window.parent or window.top is the current window.

or



JS determines whether the current page is a popup window

Determine whether the current window is opened via window.open.

Some browserswill set window.opener to window in some cases. This is the most reliable pop-up check I use right now.



Summary

Determine whether it is a top-level window or an iframe or popup window

(End)





Previous:StackBlitz front-end projects are edited and shared online
Next:HTML5 PostMessage cross-window communication
 Landlord| Posted on 7/30/2022 10:42:58 AM |
 Landlord| Posted on 7/30/2022 10:08:00 PM |
HTML5 PostMessage cross-window communication
https://www.itsvse.com/thread-10343-1-1.html
Posted on 8/1/2022 11:01:15 AM |
Useful this has learned;
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com