The difference between opener and parent in JS

Source: Internet
Author: User

Opener that who open my, such as a page with window.open pop up the B page window, then a page is located in the window is b page

Opener, a page can be accessed via the opener object on page B.

The parent indicates that a page, such as an an A, uses an IFRAME or frame to invoke page B, then the page A is the parent of page B. In JS, Window.opener is just a reference to the pop-up window's parent window. For example: a.html, window.open a new window b.html by clicking the button. In b.html, you can use Window.opener (omit write as opener) to refer to a.html, including A.html's document and other objects, to manipulate the contents of a.html. If this reference fails, then NULL is returned. Therefore, before invoking the opener object, you should first determine whether the object is null, otherwise the "object is empty or does not exist" JS error.

<a class= "under" href=# > Add </a> </form> </body>

Write as: window.opener.document.getElementByIdx_x_x ("name"). Value = "Data entered"; ============================================ Common misconception: Parent page window.open (' open.jsp? City= ' +strcity, ', ' width=252, height=100, Scrollbars=no '); Sub-page open.jsp Window.parent.maplet.clean (); Error Window.parent.maplet is empty or not an Object! What's the reason? No other problem! Cause of Error: Window.parent represents the parent frame of the current frame, if the child window is not in the frame, then it is empty, not the relationship between the child window and the parent window, and the relationship between the frames. If the child window is not in the frame, that is, the b.html page that is opened by a link to a.html, the b.html refers to the a.html form element, which can be written as follows: Window.opener.document.formname.maplet Where FormName is the name of the form in your parent window

Reproduced:

Yuntao (lost himself)Http://blog.sina.com.cn/shangguanyuntao

The difference between opener and parent in JS

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.