window.open object change parent element? - javascript

I'm not the most javascript savy. I've seen posts for children windows getting parent values but not vice versa.
Basically, I want to invoke a window object with window.open. After some user input is entered in the new window, I want to stuff that input into the original window that invoked the window.open.
The only ways I can think to do this are messy. I don't need any code examples. But if it is possible and you can example it to me I would be grateful.

When you open a new window, window.opener contains a reference to the parent window (i.e. the window that opened this window).

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.

Parent's Reference to Child Window Breaks upon Child Form Submit

I have an application containing a JavaScript view model controlling it.
The application launches a new window with (window.open()) and assigns click event listeners to buttons in the new window. New window contains a form, which when submitted, causes an unload event on its window, and thus breaking access to it from the parent window.
How can the parent's reference to this new window persist or reinstate, when the window 'unloads' and a form submits?
You can not keep that reference. However if you are trying to access some kind of values you may look into cookies or local storage.
You can also try to reinstate the reference by attaching an event listener to the "unload" event. When the event occurs close the current "parent" window, and make the "submit" script point to the parent window. Once opened you can re-open the child window from there.
Update
Cross-window javascript is a messy subject. I advise taking the first approach if it's applicable.
As far as I know, not all browsers allow to regain access to a window by name even if you provide it. But I'd still try to use distinct window names with window.open.
When trying to regain access to it - just do a window.open without url - maybe javascript:void(0) as address (so the window doesn't navigate away), it should be the same window as long as you use the same id.
it's pretty hacky though

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.

Refresh the parent window from the second child window in 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?

closing window without window.open();

Is there any way to close a new tab window that was not opened using window.open();?
No. If you didn't open the window you are not supposed to close it.
Please see here: http://www.infimum.dk/HTML/JSwindows.html#ref_3_11
In order to close a specific window using the window.close() method you need a reference to that window, which you can usually get when opening a window using the window.open() method.
Another option I can see is to use global window/frame references (self, parent, opener, etc...You can see the list in the link above as well).

Categories

Resources