windowOpened and our necessary functionality to open and close the window :
That’s basically it. So to see it in action, we would just need to wire up two buttons to handle showing and hiding the window :
<input type='button' value='Create Popup' onclick='openWindow();' /> <input type='button' value='Close Popup' onclick='closeWindow();' />
No Child Left Behind
If you wanted to ensure that you didn’t leave a poor orphaned popup window all by its lonesome if the parent page navigated elsewhere, you would just need to add the
closeWindow() function to the onunload event from the body element of your parent page :
You can find a full working example of this post available here.