Floating layer embedded IFRAME and Frame Collection window, multiple methods to refresh the parent page
JS Code
The code is as follows |
Copy Code |
<script language=javascript> Parent.location.reload (); </script>
|
Popup child page
JS Code
The code is as follows |
Copy Code |
<script language=javascript> Window.opener.location.reload (); </script> |
child window refreshes parent window
JS Code
The code is as follows |
Copy Code |
<script language=javascript> Self.opener.location.reload (); </script> |
Instance
Need to edit the information in the newly opened window, and so on, you need to close the current window and refresh the parent window, so that the changes take effect, this article is about using JavaScript to implement "update records after the child window and refresh the parent window."
Refreshes the parent window and closes the current window
Parent Window Code:
The code is as follows |
Copy Code |
<a href= "javascript:void (0)" onclick= "window.open (' child.html ', ' child ', ' width=400,height=300,left=200,top= 200 '); " > Open child windows </a> |
child Window Code:
code is as follows |
copy code |
<script Language= "JavaScript" type= "Text/javascript" > <!-- function refreshparent () { Window.opener.location.href = window.opener.location.href; if ( Window.opener.progressWindow) { Window.opener.progressWindow.close (); } Window.close ();} //--> </script> <a href= "javascript:void (0)" onclick= "Refreshparent ()" > Refreshes the parent window and closes the current window </a> |
Refreshing a window opened with the open () method
JS Code
The code is as follows |
Copy Code |
<script language=javascript> Window.opener.location.href=window.opener.location.href; </script>
|
Refreshing a window opened with the Winodw.showmodeldialog () method
Java code
The code is as follows |
Copy Code |
<script language= "JavaScript" > Window.parent.dialogArguments.document.execCommand (' Refresh '); </script> |
to summarize some of the above methods, let's do an example .
Interaction between parent window and child window in Javascript
We need to interact in the parent and child windows, such as uploading files in a child window, and returning the uploaded results to the parent window. This article is about a simple interaction instance. If your mind is flexible enough
The code is as follows |
Copy Code |
<script type= "Text/javascript" > <!-- function Openwindow () { NewWindow = window.open (', ' newwindow ', ' Height=300,width=300,scrollbars=auto '); if (NewWindow!= null) { var windowhtml= "windowhtml + = "<body> windowhtml = "This is the child window!windowhtml + + <input type= ' button ' value= ' sets the background of the parent window to red ' onclick= ' Window.opener.document.body.style.backgroundcolor= "Red"; '/><br> '; windowhtml + = "<br ><input type= ' button ' value= ' Close ' onclick= ' self.close (); '/> '; windowhtml = "</form></div></body> NewWindow.document.write (windowhtml); Newwindow.focus (); } } --> </script> <input value= ' open child window ' onclick= ' Openwindow (); "type=" button "> <input type=" button "value=" sets the background of the child window to blue " Onclick= ' if (window.newwindow) {newwindow.document.bgcolor= ' blue '; Newwindow.focus ();} '/> |