Javascript showmodaldialog, open method to get the parent window

Source: Internet
Author: User

Window. Open is usually used to open a new window.
To obtain the control of the parent window, you can use window. opener to obtain the parent window.
However, if showmodaldialog is used, it is invalid.
If necessary, you need to modify the enabled syntax and the syntax in showmodaldialog.
To enable the syntax for the 2nd parameters, see self. The example is as follows:
VaR rc = Window. showmodaldialog (strurl, self, sfeatures );
Then there is the syntax for calling the parent window.
VaR pwindow = Window. dialogarguments;
In this way, the window object control of the parent window can be obtained. For example:
Optional values dialogarguments.doc ument. getelementsbyname ("processid") [0]. value;

Differences Between Opener and parent in JS

opener refers to the person who opens my project. For example, a page uses window. when the open dialog box is displayed, the window where page A is located is the
opener of page B. You can access page a through the opener object on page B.
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, click "click the button" and click "Export" to create a new window B .html. In B .html, The a.html content can be operated through
accessing the opener(specifically, using opener.pdf to reference a.html, including a.html documentobject.
If the 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 null or does not exist" will occur. copy Code the code is as follows:






Back2opener.htmlCopy codeThe Code is as follows: <HTML>
<Body>
<Form. Name = form1>
<Input type = text name = inpu>
<A class = under href = #> Add </a>
</Form>
</Body>
</Html>

Window. Opener returns the reference of the window that creates the current window.
B .htm, then we can input a value on B .htmand assign it to a textbox with the ID "name" on a.htm.
Written:
Optional values opener.doc ument. getelementbyid ("name"). value = "input data ";

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.