Open PopUp and Notify when closed
Open the window from parent window and closed notify the parent window and do some operations.
by Pratik Bhoir
HTML
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Parent</title>
</head>
<body>
<div>
<h2>Open ChildWindow and Notify when it's closed</h2>
<br />
<br /> <a href="http://msdn.microsoft.com/en-us/library/ms536651%28v=vs.85%29.aspx" target="_blank">For More Info onOpening Windows</a>
<br />
<br />
<br />Open the Child Window
<button id="btn" onclick="openPopup()">Open Popup</button>
<br />
<div id="msgDiv"></div>
</div>
<script type="text/javascript">
var msg = document.getElementById("msgDiv");
function openPopup() {
//use null instead of window name 'onlyOne'. if you want to open multiple windows. Adding Name opens only one instance of that window by that name.
var childWindow = window.open("", "onlyOne", "height=200, width=400, status=yes, toolbar=no, menubar=no, location=yes");
//Unload Event of that child window.
childWindow.onunload = function() {
//calling a function in the parent DOM
window.parent.popupClosing()
};
msg.innerText = "ChildWindow Opened";
}
function popupClosing() {
//do stuff after closing
msg.innerText = "ChildWindow is been closed";
}
</script>
</body>
</html>