How do I find a child window when the parent is refreshed?
hejdig.
In a web solution I want to reuse my child window but lose the reference to it when the main window refreshes. How can I find an orphaned child window? (which is orphaned due to parent refresh)
/OF
Situation:
- Parent window exists.
- User presses button to open Child window.
- User enters text in Child window.
- User asks Parent window to refresh.
- User presses button to open Child window.
- Child window refreshes and user's text is gone.
In my case the Parent is a CMS and it is quite natural for it to reload when the user looks at a new article; this situation isn't new.开发者_StackOverflow社区 What is new is that I have an editable child window.
So the real-world situation is like:
- User browses a site (a CMS).
- User opens a popup and is asked to enter some data.
- User enters some data in the popup.
- User decides to look at a new article (gets a new URL in parent).
- The popup is now hidden so the user clicks top open the popup again.
- The popup is refreshed (what I try to avoid) and focused.
The only workarounds I have found is to use iframe, frameset or open a third window and none of these solutions are possible in my situation.
Calling
wnd = window.open( "", "uniquename" );
doesn't work since it reloads the child.
Untried ideas are to check if the wnd handle is unique for the browser session and store it in a cookie or similar. Another untried idea is if the child can find out if it is orphaned and then, through a timer, try to find its parent.
hi as you said yourself try putting timer in child which will registeritself to prent so in parent create function
var wnd = null;
function registerChild(child){wnd = child}
and in child in timer every second or half
window.opener.registerChild(window);
精彩评论