Javascript - Close Popup page and reload main page at same time

Hi E's,
I have one page that open a pop-up page when I click in the link:
 
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>main page</title>
</head>

<body>
<a href="#" onClick="window.open('1007_2.php', 'edit', 'height=200,width=550,resizable=no,toolbar=no,menubar=no');return false;">edit</a></div>
</body>
</html>

Open in new window


...and I have the pop-up page that contain a link to close the pop-up window
 
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>popup page</title>
</head>
<body>
<a href="javascript:window.close();">close and reload main page</a>
</body>
</html>

Open in new window


The behavior is simple, main page open a pop-up and this pop-up have a button for close them self.

The question is, what changes I have to do in my code for when I click to close the pop-up, in the same time the main page reload.

Note the objective here is, in pop-up I will made some updates to data-base, and the main page will show that data has been change.

The best regards, JC
LVL 3
Pedro ChagasWebmasterAsked:
Who is Participating?
 
nap0leonCommented:
change line 7 of your popup:

<a href="javascript:window.opener.location.reload(true);window.close();">close and reload main page</a>
main.html
popup.html
0
 
nap0leonCommented:
If you want the reload to work when the user clicks the "X" to close the popup...
try changing line 6 of the popup to:

<body onunload="window.opener.location.reload(true);">
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.