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 ";