Problem: Need to get a handle of an already opened javascript popup window (handle = window.open(…)) from its opener window, multiple requests later after its opener (parent) window has been refreshed and javascript variables reset.
For example, parent window could have javascript as follows:
<script type="text/javascript">
var popupHandle;
function openPopUp() {
popupHandle=window.open('http://www.google.ca', 'popupTest');
popupHandle.focus();
return popupHandle;
}
// To get handle, need to reopen popup with same name as original (popupTest).
function getPopUpHandle() {
return openPopUp();
}
// If getting handle to close, open as small as possible and close so it’s not too noticeable.
function closePopUp() {
popupHandle=window.open('', 'popupTest', 'directories=no,location=no,menubar=no,status=no,resizable=no,scrollbars=no,titlebar=no,top=1,left=1,width=1,height=1');
popupHandle.close();
}
</script>
If you know of a better solution, please let me know.
How I am using it in my app: I have a list of images displayed on one side of the screen. On the other side I have a form that allows me to submit information based on the image. When the form is submitted, it attaches the image referenced.
When an image is clicked on, it opens in a popup.
When the form is submitted, the next image in the list should open in the popup. The popup could have been closed by the user.