Differences between window. parent and window. openner

Source: Internet
Author: User
Today, we will summarize the differences and usage of several objects in js: parent. window and top. window Usage & quot; window. location. href & quot;, & quot; location. href & quot; indicates the current page Jump & quot; parent. location. href & quot; is the previous page Jump & quo

Today, we will summarize the differences and usage of several objects in javascript:

First, the usage of parent. window and top. window

"Window. location. href" and "location. href" indicate the current page Jump.

"Parent. location. href" is the previous page Jump

"Top. location. href" is the outermost page Jump

Example:

If A, B, C, and D are all jsp, D is the iframe of C, C is the iframe of B, and B is the iframe of A, if js in D is written like this

"Window. location. href", "location. href": D page Jump

"Parent. location. href": C page Jump

"Top. location. href": A page Jump

Now I understand the usage of target during connection:

_ Blank: open a new window

_ Parent: the parent window is redirected.

_ Self: Page redirection

_ Top: redirection of the first parent window

In conclusion, parent. window: parent window object top. window: first parent window object

Next, let's take a look at the differences between window. parent and window. openner.
Window. parent is the parent page object called by the iframe page. When we want to access the outer page from the embedded page of iframe, we can directly use window. parent to obtain it;

Example:

A.html



Parent page




B .html



Related Article

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.