Refresh Parent page when Child window closes
The code sample contains code for two HTML pages - parent and child. We aim to call a child page from the parent by using Javascript functions and refresh the parent page when the child window is closed.
The code for refreshing is contained in the child page.
Code for the parent page Main.html is next:
<html>
<head>
<title>Main Window</title>
<script Language = "JavaScript">
function OpenWin()
{
window.open("Child.html", "Child",'width=300,height=200,left=150,top=100,scrollbar=no,resize=no');
}
</script>
</head>
<body>
<h4>Click the button to open a new window.</h4>
<input type="button" value="Click Me" onclick="OpenWin();"></br>
</body>
</html>
Save the followin code as Child.html
<head>
<title>Child Window</title>
<script Language = "JavaScript">
function CloseWin()
{
window.close();
opener.location.reload();
}
</script>
</head>
<body>
<h4>Click the button to close the window.</h4>
<input type="button" value="Click Me" onclick="CloseWin();">
</body>
</html>
Hi
You can also use "window.opener" for accessing the parent page.
Thanks
A S