Window. opener, via window. open the reference of the parent form of the child form. The following describes how to use it in detail. If you are interested, refer to window. opener, via window. open refers to the parent form of the child form.
For example, in the parent form parentForm, window. open ("subForm.html") means window. opener represents parentForm in subForm.html. Since the reference of the parent form can be obtained in the child form, you can set the field value of the parent form in the child form or call the js method.
Instance: when adding personnel information, the organization information is entered in the subform.
Father form, used to add personnel information.
After the child form is input, the organization information (id and name) is automatically filled in the orgId and orgName fields of the parent form.
Html code
The Code is as follows:
Institution
Onclick = "openWin ('org. do? Select = true ', 'selectorg', 800,500, 1) ">
JS Code
The Code is as follows:
/*
* Open a new window (via window. open ())
* F: link address
* N: Window name
* W: The window width.
* H: window height
* S: whether the window has a scroll bar; 1: A scroll bar; 0: No scroll bar.
*/
FunctionopenWin (f, n, w, h, s ){
Sb = s = "1 "? "1": "0 ";
L = (screen. width-w)/2;
T = (screen. height-h)/2;
SFeatures = "left =" + l + ", top =" + t + ", height =" + h + ", width =" + w
+ ", Center = 1, scrollbars =" + sb + ", status = 0, directories = 0, channelmode = 0 ";
Openwin = window. open (f, n, sFeatures );
If (! Openwin. opener)
Openwin. opener = self;
Openwin. focus ();
Returnopenwin;
}
Sub-form for selecting organization information.
After selecting (Click radio), the organization information (id and name) will be filled in the orgId and orgName fields of the parent form
Html code
The Code is as follows:
$ {Org. id}
$ {Org. name}
$ {Org. sn}
$ {Org. parent. name}
JS Code
The Code is as follows:
FunctionselectOrg (id, name ){
If (window. opener ){
Zookeeper opener.doc ument. all. orgIdId. value = id;
Zookeeper opener.doc ument. all. orgNameId. value = name;
Window. close ();
}
}
Result After selecting organization information
The organization information (id and name) is entered, but the id is in the hidden domain and cannot be seen.
Summary
When it comes to references to the parent form, besides window. opener, It is window. parent. Window. opener is used to open sub-forms through window. open, while window. parent is used to open sub-forms through iframe.