开发者

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:

  1. Parent window exists.
  2. User presses button to open Child window.
  3. User enters text in Child window.
  4. User asks Parent window to refresh.
  5. User presses button to open Child window.
  6. 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:

  1. User browses a site (a CMS).
  2. User opens a popup and is asked to enter some data.
  3. User enters some data in the popup.
  4. User decides to look at a new article (gets a new URL in parent).
  5. The popup is now hidden so the user clicks top open the popup again.
  6. 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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜