Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieve value from popup jsp to javascript

Tags:

javascript

jsp

I am opening a popup window (JSP page) using JavaScript.

I am setting some value in the popup and doing window.close().

Now, I am to return that value to the main page from where I had opened the popup through JavaScript.

How can I retrieve the value?

like image 816
Anwesha Mohanty Avatar asked Mar 07 '26 17:03

Anwesha Mohanty


1 Answers

In your jsp page add this :

function onPopupClose(returnParameter) {
   // Process returnParameter here
}

window.open('popup.jsp?parameter='+param,'mywindow','width=500,height=350,toolba‌​r=no,resizable=no,menubar=no');

Then in your popup jsp, before calling window.close , add this line :

window.opener.onPopupClose(myValue);//myValue is the value you want to return to main javascript
window.close();
like image 88
Stephan Avatar answered Mar 10 '26 06:03

Stephan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!