Close Window and Refresh Parent Window

Yazici
Yazici used Ask the Experts™
on
Hi There,

I've got a script that allow users to add notes about a users account. When they click on add notes, a pop-up box appears, in which they can add notes and press submit, which adds it to the database.

What I want to be able to do is, when they press submit, the data is written onto a different page which then (for simplicity) goes to a different page and that page automatically closes the small window and also refreshes the main window, so that the new added note can be displayed.

Any ideas on how to do this? I know closing the window isn't hard, especially as it's a browser opened one, so it will not come up with the usual message of the webpage is trying to close this window. What I really need to know is how to send a refresh command to the main window or get it to load the current page or something along those lines.

Cheers

Bulent
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Popup.htm (Popup Page)
---------

On submit click,

function RefreshMainWindow()
{
   //your code
   window.opener.RefreshPage();
   window.close();
}

MainPage.htm (Your main Page)
------------

function RefreshPage()
{
   window.history.go(-1);
}
Commented:
you can try to send the following script to your popup window.:

<html>
<head>
<script>
window.opener.location.reload();
window.close();
</script>
</head>
<body>
</body>
</html>

depending on the language you are using, thsi would be, for example in php this like:
echo '<html>';
echo '<head>';
echo '<script>';
echo 'window.opener.location.reload();';
echo 'window.close();';
echo '</script>';
echo '</head>';
echo '<body>';
echo '</body>';
echo '</html>';

Author

Commented:
Cheers guys.. I did this:

<script language="JavaScript" type="text/JavaScript">
<!--
function RefreshMainWindow() { //v2.0
  window.opener.location.reload();
  window.close()
}
//-->
</script>
<body onLoad="RefreshMainWindow();">

Author

Commented:
Cheers guys.. I did this:

<script language="JavaScript" type="text/JavaScript">
<!--
function RefreshMainWindow() { //v2.0
  window.opener.location.reload();
  window.close()
}
//-->
</script>
<body onLoad="RefreshMainWindow();">

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial