1: window. parent is the parent page object called by the iframe page
Example:
A.html
Program code <Head> <title> parent page </title> <Body>
<Form name = "form1" id = "form1">
<Input type = "text" name = "username" id = "username"/>
</Form>
<Iframe src = "B .html" width = 100%> </iframe>
</Body>
</Html>
To assign a value to the username text box in a.htm in B .htm, for example, many upload functions. The upload function page is in Ifrmae. After the upload is successful, the uploaded path is placed in the text box of the parent page.
We should write in B .html
Program code <script type = "text/javascript">
Var _ parentWin = window. parent;
_ ParentWin. form1.username. value = "xxxx ";
</Script>
2: window. opener is a child page opened by window. open. It calls the parent page object.
A.html
Program code <script type = "text/javascript">
Function openSubWin ()
{
Var _width = 300;
Var _ height = 200;
Var _ left = (screen. width-_ width)/2;
Var _ top = (screen. height-_ height)/2;
Window. open ("B .html", null,
"Height =" + _ height + ", width =" + _ width + ", status = no, toolbar = no, menubar = no, location = no, resizable = yes, left = "+ _ left +", top = "+ _ top );
}
</Script>
<Input type = "text" name = "username" id = "username"/>
<Input type = "button" value = "pop-up subpage" onClick = "openSubWin ();">
B .html
Program code <script type = "text/javascript">
Function UpdateParent ()
{
Var _ parentWin = window. opener;
_ ParentWin. form1.username. value = "xxxx ";
}
</Script>
<Input type = "button" name = "button" id = "button" value = "update the UserName content on the home page" onClick = "UpdateParent ();">