Example given below is to refresh the parent window from the child or pop up window.
The child window has a button, which when clicked refreshes the parent window. This could help in situations like; there might be some kind of operation done in child window, but also need to reflect in parent window before closing the pop up or child window.
Parent window:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Parent</title>
</head>
<body>
<form id="prntfrm">
<input type="button" value="Open" onclick="window.open('child.htm');"/>
</form>
</body>
</html>
Child window:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Child</title>
</head>
<body>
<input type="button" value="Refresh Parent Window" onclick="opener.document.location.reload();if(confirm('Would you like to close this window?')){window.close();}"/>
</body>
</html>
When you click on ="Refresh Parent Window" button child window, you can observe the parent window is refreshed.
No comments:
Post a Comment