This sounds very complicated (read: problematic).
What you're asking has been an issue since way back and goes back to the original HTTP protocol.
The short answer is no, this isn't really possible. When you refresh the parent all references to the children are lost. In all actuality it's quite realistic.... parent is "refreshed".... children get all the resources the parent left behind... sorry, off topic and well yea. The Web is stateless, so once a page is refreshed, reloaded, closed, opened, or had any other verb attached to it, the page is treated as a new document.
This works fine in chrome/FireFox, but does not work in IE.
Something like the following will work, but in order to reattach that relationship between child/parent it must be done FROM the child. The script/markup below will give an example.
So I wouldn't use it, but it's here just as an example.
Steps:
- Open Child
- Go to Child
- Refresh Parent
- **Parent -> Child relationship is lost.
- **Child -> Parent relationship still exists.
- Link Parent
- Go to Parent page
- Check Relationship
- **You will see the parent is now not null
- Stay ON parent
- Refresh Child
HTMLPage.htm:
<input type="button" onclick="openChild();" value="Open Child" />
<input type="button" onclick="refreshParent();" value="Refresh Parent" />
<input type="button" onclick="linkParent();" value="Link Parent" />
<input type="button" onclick="checkRelationship();" value="Check Relationship" />
<input type="button" onclick="refreshChild();" value="Refresh Child" />
<script type="text/javascript" language="javascript">
var child;
function openChild() {
child = window.open("HTMLPage.htm");
}
function refreshParent() {
alert("refreshing parent");
window.opener.location.href = window.opener.location.href;
}
function linkParent() {
window.opener.child = window;
checkRelationship();
}
function checkRelationship() {
alert("Parent: " + window.opener + ". Children:" + child);
}
function refreshChild() {
child.location.href = child.location.href;
}
</script>
So then my next question is:
What are you trying to achieve with this? I'm all for using a modal window / pop up window when the situation really calls for one, but do you need an array of them?
Does the parent page "need" to refresh? Could you stick an iframe on the parent page and refresh that (IE. file uploads etc. where the main page doesn't "need" to refresh).
I'm far from an apple fan boy, but this link does give a good insight on using IFrames with scripting: http://developer.apple.com/internet/webcontent/iframe.html
I hope this helps.