We only need to use newclientclientdoc ument. getElementById and opener. location. reload to operate on each other. You can refer to them.
1. Pass a value from the Child Window to the parent window
If the parent page has a control id of choosedProvider, you can pass the value to the parent page:
The Code is as follows: |
Copy code |
Opener.doc ument. getElementById ("choosedProvider"]). value = "Tom "; |
2. Pass a value from the parent window to the Child Window. For example, if the child window contains a control whose id is T, you can use the following values:
The Code is as follows: |
Copy code |
<Script> Var newWindow; Function openWindow (url ){ NewWindow = zookeeper open(“new.htm "," "," width = 400, height = 300 "); } Function changeChild (){ Newmediaworkflow Doc ument. getElementById ("T"). value = "I changed "; } </Script> |
When a child window is closed again, the parent window is automatically refreshed.
Close the parent window when the child window is closed:
Opener. location. reload ();
Window. close ();
The actual effect is as follows: Open 1.htm, click link to new window 2.htm, click link in 2.htm, and close the new window.
1.htm window redirection.
The 1.htm code is as follows:
The Code is as follows: |
Copy code |
<Html> <Body> <A href00002.htm onclick00000000000000000000open('2.htm') "> new </a> </Body> </Html> |
2.htm code:
The Code is as follows: |
Copy code |
<Html> <Body> <A href = # onclick = "opener. location. href = 'HTTP: // baidu.com '; window. close ()"> nbn </a> </Body> </Html> |
We only used the Child Window to operate the upper-pole window. Of course, we can also operate the child parent window together.
Close the child window when the parent window is closed. This is to use the method to detect the onunload Event of the parent window:
The Code is as follows: |
Copy code |
<Script> Var newWindow; Function openWindow (url ){ NewWindow = window. open (url, "", "width = 400, height = 300, resizable = yes "); } Function closeChild () { NewWindow. close (); } </Script> Add the onunload Event to the body: <Body onunload = "closeChild ()"> |