I found a link that shows how to send parameters back to the opener browser window. But it works only with window.showmodal()
. There should be an easy way to do the same if I use window.open()
right?
From a child window or a small window once opened, we can transfer any user entered value to main or parent window by using JavaScript. You can see the demo of this here. Here the parent window is known as opener. So the value we enter in a child window we can pass to main by using opener.
returnValue = true; window. close();
In the HTML markup of the Child page we need to place the JavaScript function RefreshParent which is called attached to the browser onbeforeunload event. Thus when the Child page popup window is closed the parent page is refreshed.
If you are using window.open, you can call a function in the parent window and pass in pararmeters to that function.
Do this in child page javascript
var x="hello";//parameter I want to pass to the parent
window.opener.ParentPageFunctionName(x);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With