Refresh the parent window from the second child window in Javascript - javascript

The work flow is like this, from my page, I created a popup using window.open method, then open other popup from that window and close its immediate parent, and I need to refresh the first parent page from this popup. I tried in different ways, but the window.opener method can't get the parent windows property.
Can anyone help me to solve this?

Related

i am opening new window popup using javascript which will restrict user from using its parent window

I am opening new window pop up using window.open method which will restrict user to use its parent window till the new window is not closed. User will not be able switch back to parent window till child window is open.
How can I do it using JavaScript? please guide me..
To disable the parent window until child window closed you might want to use window.showModalDialog() instead of window.open().
To use showmodalDialog click here
note: However, that you can not use window.opener from a modal dialog box (it will always be null) unless you explicitly pass a reference to the parent window in the second argument to showModalDialog() and get it back using window.dialogArguments.

Window.opener with child window navigate in same window not working

I have scenario like P is parent page and from that page one child page is being open using window.open(C) where C is child page. Now I have to navigate in same child window. Let's call that page as C1.
I found when I try to access one button of page P from page C1, it gave me not found.
My syntaxt is like (in page C1),
window.opener.document.getElementById('xyz');
Is there any way using which I can identify the page I am getting in window.opener is same page what I am looking for?
You ask:
Is there any way using which I can identify the page I am getting in window.opener is same page what I am looking for?
Just an idea: generate some random value before opening the new window and store it in the parent window, write this value to the new window and cross-reference.
Update:
You can share data between parent and child browser windows at some scenarios as shown below:
window.opener.functioname(arg1,arg2,..)
- to send data to the parent window from child window
winobj.functioname(arg1,arg2,..)
- to send data to the child window from parent window using the window handle got from window.open()
See for a lot more info on this page.
Good luck!
I am using FCKEditor on my parent page and child page opened from that editor only. So I have to have use window.opener.parent.my_function();
Thanks a lot to all who helped me.

open new window using javascript which will restrict user from using its parent window

I want to open a new window using window.open method which will restrict user to use its parent window till the new window is not closed. User will not be able switch back to parent window while child window is still open.
How can i do it using javascript? please guide me..
If you want the popup window to be modal (i.e. to disable its parent window until it's closed), you might want to use window.showModalDialog() instead of window.open().
Note, however, that you cannot use window.opener from a modal dialog box (it will always be null) unless you explicitly pass a reference to the parent window in the second argument to showModalDialog() and get it back using window.dialogArguments.

Maintaining a specific window hierarchy in javascript

so i am writing some javascript to handle multiple windows and i need a way to enforce the following hierarchy: the main window should be parent to all other windows opened, regardless of where those other windows were opened from. ie. if the main window opens a child using window.open(), and the child opens a window using window.open(), these two child windows need to be siblings and children of the main window, currently one child is parent to the other and this is causing problems. is there any way to refer to the parent window before calling window.open() so the parent is set as the parent of the new window, instead of the window the javascript function is called from?
i tried this without success, but it may be close:
if (window.opener && !window.opener.closed) {
window.opener.functionThatEventuallyOpensAWindow();
} else {
functionThatEventuallyOpensAWindow();
}
if anyone has any ideas it would be greatly appreciated. please note that this code segment can not directly use window.open(), but must call other functions which eventually end in a window.open().
Found the fix. I needed to follow the function calls down to the actual window.open and add to some logic to detect if i was in a child and, if i was, call window.opener.open() instead. not sure why it was not able to change context earlier in the call stack, but it works :)

Refreshing a parent window when both are modal

This is a tough one that's left me high and dry, because its a unique variation on a more common problem.
I have a modal parent window spawning a modal child window (with a standard window.showModal call to open it). The user performs some actions on this new page, and then closes it. On the close, I want to refresh the parent modal window.
What makes this tough is that both are modal. I've seen solutions for how to refresh normally (window.opener.location.refresh(true)) and if the child is a modal window (window.dialogArguments.location.reload(true); where the parent window is passed as the 2nd argument).
Any suggestions on what to do? I think the modal nature of the parent is breaking the refresh, and I can't figure out how to work around it.
When you open a Model window with window.showModalDialog the code in the parent page is stoped, so the code after the opening of the modal window won't be executed until the child is closed.
Having said that, just try:
// Open the modal dialog
window.showModalDialog('your/child/url.com')
// after is closed, the parent will refresh it self
window.location.reload();

Categories

Resources