7

I am trying to achieve the following.

  1. A link on a parent page will open a new child pop-up.
  2. In the child pop-up, the user enters some data and clicks “Save”.
  3. Data will be saved to database and the pop-up will be closed. The parent window would be refreshed, and the data entered in the child pop-up would be displayed in the parent page.

How can this (closing a child pop-up and refreshing the parent page) be done in Javascript?

TRiG
  • 9,687
  • 6
  • 54
  • 105
cool2cool
  • 71
  • 1
  • 1
  • 2

3 Answers3

11

In the pop-up window:

<script type="text/javascript">
function proceed(){
   opener.location.reload(true);
   self.close();
}
</script>

<form onsubmit="proceed()">
...
</form>
derekcohen
  • 1,494
  • 4
  • 17
  • 31
5

In the popup's code for closing/reloading:

opener.location.reload();
close();
Delan Azabani
  • 76,631
  • 25
  • 162
  • 208
3

parent.html

<a href="#" onclick='window.open("child.html","_blank","height=100,width=100,
status=yes,toolbar=no,menubar=no,location=no");return false'>pop up</a>

child.html

<p>child window</p>
<script>
window.onload = function(){
    window.opener.location.reload(true);
    window.close();
}();
</script>
erickb
  • 5,925
  • 4
  • 24
  • 19