Here is the scenario:
I'm in parent window. I click on a link, which opens a child window
Now I'm in child window, I enter some data and click on a submit button
Now, the child window refreshes. After the child window completes refreshing, the parent window refreshes.
After the parent window refreshes, the child window goes background, which I don't want. I want that to remain foreground.
NOW, I searched how to get the reference of child window from the parent window and found this link-
http://www.codeproject.com/Articles/25388/Accessing-parent-window-from-child-window-or-vice#b
My question is - Will I be able to successfully get the reference of the child window even after the parent window has refreshed?
More info: This happens only in IE and not in Chrome/Firefox.
UPDATE: As per this link - https://www.daniweb.com/programming/web-development/threads/48485/parentchild-windows-references
The parent will not have control over child anymore. But is there a way I can maintain the focus on the child window even after the parent window refreshes?
Related
In my application there is a parent window. It opens a new child window which in turn opens a new child window. During this the parent window references is lost and hence not able to access parent form elements in the child window. It is working in IE.
I want to refresh the parent window after closing the pop up window.
I have used
window.opener.location.reload();
This works fine in one case when the parent window is the calling window. But there is another scenario where we set the parent of the calling window as another window.
So instead of loading the calling parent window it loads the other page. Can we set a fixed parent window as in my case its obviously changing due to some business rules.
I am calling the parent page javascript function from child window with code below, which displays some alert message on parent page and closes the child window.
window.opener.CallAlert("test is"+test);
opener.focus();
self.close();
What is happening with above code snippet is alert comes on parent window but focus remains on child window. i need explicitly go to parent window. Once I click ok on alert child window closes.
Everything is fine but I want the to focus on parent window once i call the window.opener.CallAlert() from child window.
Edit
Looks like opener.focus(); works on IE but not mozilla. Any workaround for firefox?
It would appear that this is not guaranteed to work and is at the discretion of the browser.
See this thread: window.opener.focus() doesn't work
just try the obvious:
window.opener.focus();
try with delay setTimeout(function(){self.close()},300) and then display alert on parent page. It will schedule to close the current window after some delay automatically with display of alert message on parent signal
I want a page that open child window. The child window will be redirect to other website for processing. The other website will send the result to our server by redirect on the child window.our server will process the result and return to parent window and close the child window. Can it be done and how?
You use window.open method to open a child window and store the returned reference to interact with it later.
You use the window.parent property from the child window to access the parent window.
Here is an article demonstrating the approach.
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. 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);