Anwesha Mohanty
Anwesha Mohanty

Reputation: 31

Retrieve value from popup jsp to javascript

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?

Upvotes: 3

Views: 2197

Answers (1)

Stephan
Stephan

Reputation: 43013

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();

Upvotes: 1

Related Questions