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, b page through the opener object can access a page. 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. --------------------------------back2opener.html--------------------------------Window.opener Returns a reference to the window that created the current window, such as clicking on a link on a.htm and opening the b.htm, and then we're going to enter a value on b.htm and give it a TextBox with the ID "name" on the a.htm. It can be written as: Window.opener.document.getElementById ("name"). Value = "Data entered";

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.