Pronunciation / adjective
Bringing something good and unforseen.
    Skip Navigation Links > Code Repository

Close a popup window and refresh the parent window


Close a popup window and refresh the parent window

Using a separate .htm web page a popup window may be closed and it's parent window refreshed.

One scenario in which you may want to do this is if you popup a window for a user to add or remove an item from a databased list of items which are shown in the parent window.

Make a Redirect.htm file with the following code:
  1. <html>
  2. <head>
  3. <title>Refresh Parent</title>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  5. <script language="JavaScript">
  6. <!--
  7. function refreshParent() {
  8. window.opener.location.href = window.opener.location.href;
  9. if (window.opener.progressWindow) window.opener.progressWindow.close();
  10. window.close();
  11. }
  12. //-->
  13. </script>
  14. </head>
  15. <body onLoad="refreshParent()">
  16. </body>
  17. </html>

When you want to close the popup window and refresh the parent just redirect the popup window's location to:
  1. redirect.htm

Microsoft Certified Professional   © 2018 Fortunate.  All rights reserved.