Parent Window access lost in child's child window - javascript

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.

Related

Reload parent window when parent window changes

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.

Getting Child window reference from parent after parent is refreshed

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?

parent window open child window

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.

About Popup window data to Parent window

I am opening one Popup window on Button Click in main window, it is for Image Uploading.
when I am uploading Image , i.e. on Upload button click I am closing this Popup window and opening new Popup window.
And Now I want to display the Popup data to Parent window without refreshing, But I am not getting Parent window object.
i.e. window.opener or window.parent. Please give me help. How I will get Parent window object?
you can try this,
When first popup window is opened(uploading image window) get parent window object for this popup and store in some variable(java script variable ) like this
var parentWindowObject=window.opener;
Try passing this object variable to the second pop up window( on upload click) and in this page you will get it main page window reference (parentWindowObject) and using this you can fire new request to main page to post your required data as follows
parentWindowObject.location="your request";
Reason for not using window.opener in second popup
As you are opening a new popup from the present popup. The parent for the newpopup will be the popup which you are opening from here is your upload popup and you are closing the upload popup once you click on upload so for the new popup the value for window.opener(a reference for the parent window) will be null.
You can access the parent window by using window.opener
See window.opener
which returns a reference to the window that opened this current window. When a window is opened from another window, it maintains a reference to that first window as window.opener. If the current window has no opener, this method returns NULL.

What's different when a page is opened by window.showModalDialog?

Anyone knows the difference?
The problem I met is that the page stops working correctly when opened by window.showModalDialog
window.showModalDialog vs window.open
Window.open will open up a new window through Javascript, with the URL and other features of the window that u pass as parameters. Here the parent window which opens the new window and the child window are independent windows.
Eg. Below
`window.open('winOpen.htm','name','height=255,width=250,toolbar=no,directories=no,status=no,
linemenubar=no,scrollbars=no,resizable=no');`
Window.showModalDialogue again works smilar to a window.open only diffrence being its a Modal window, It opens up as a new window but doesnt allow the user to access the parent window, unless you explicitly close it.
Here the child window is dependent on the parent window. If you close the parent window the child would also get closed.
window.showModalDialog("xpopupex.htm","name","dialogWidth:255px;dialogHeight:250px");
ShowModalDialogue windows can be used when u want the user to perform a particular action in the new window before he access the parent window again. like login before he can access the parent page..
tryed to make it as simple as possible...hope this help.. ;)

Categories