Differences between window. opener and parent in js

Source: Internet
Author: User



If js, window. open ("B window") is called in window ");

Then, when js is called in window B, window. opener can get window.



Parent indicates the parent window. For example, if A page A uses iframe or frame to call page B, the window where page A is located is the parent of page B. In JS, window. opener only references the parent window of the pop-up window. For example, in a.html, window. open a new window B .html by clicking a button. In B .html, you can access the.html content by writing an example of opener(specifically, opener.pdf to reference a.html, and wrap the.html documentobject.
If this reference fails, null is returned. Therefore, before calling an opener object, you must first determine whether the object is null. Otherwise, a JS error "the object is empty or does not exist" will occur.



If a frameset contains multiple frames and framset,

When obtaining the sub-frameset, you know that the parent frameset can directly use the. framset name attribute;

In addition, the. name attribute can be obtained across layers.

For example:

<Frameset rows = "20, 40, 50" cols = "*" name = "main">
<Frame src = "" name = "chid1"/>
<Frame src = "" name = "child2"/>
<Frameset rows = "*" cols = "50%, *" name = "child3">
<Frame src = "a.html" name = "child4"/>
<Frame src = "B .html" name = "child5"/>
</Frameset>
</Frameset>

When you use js in B .html to obtain child1, you can use parent. child1

When you use js in B .html to obtain child4, you can use parent. child4.

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.