Details about window. Parent, window. Top, and window. Self in JS

Source: Internet
Author: User

When the application has a frameset or IFRAME page, parent is the parent window, top is the top parent window (some windows have several layers of frameset or IFRAME), and self is the current window, opener uses the Open Method to open the current window.

 

Window. Self

Function: it refers to the reference of the current window. It is equivalent to the window attribute.

Syntax: window. Self

Note: window, self, and window. Self are equivalent.

 

Window. Top

Function: Return to the top-level window, that is, the browser window.

Syntax: window. Top

Note: If the window itself is a top-level window, the top attribute returns a reference to itself.

 

Window. Parent

Function: return to the parent window.

Syntax: window. Parent

Note: If the window itself is a top-level window, the parent attribute returns a reference to itself.

In the frame webpage, the parent window is usually the top-level window, but if there is a frame in the Framework, the parent window and the top-level window are not necessarily the same.

 

Determine whether the current window is in a framework:

<SCRIPT type = "text/JavaScript">
VaR B = Window. Top! = Window. Self;
Document. Write ("whether the current window is in a frame:" + B );
</SCRIPT>

You should regard the frame as a different area in the window, and the frame is a specific part in the browser window. A browser window can be divided into multiple frameworks according to your needs. A single framework can also be divided into multiple other frameworks, the so-called nested framework.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.