hussainian Posted August 16, 2010 Share Posted August 16, 2010 Hi!I'm working on a JSP based project. On myJsp1.jsp, I open a new window using window.open and store reference in a variable myWin likemyWin = window.open(.........);from here i submit the form to myJsp2.jsp.In this file, I want the reference myWin to close the opened window. What I'm doing while submitting form is:myWin = window.open(.............);document.onlinePayStatusSummary.action ="myJsp2.jsp?action=forwardOnlinePayRequest&childWindow=" +myWin;document.onlinePayStatusSummary.submit();I've read that this way JavaScript references can be passed in url.Now when I do getParameter in myJsp2.jsp asvar winRef = "<%=request.getParameter("childWindow").toString()%>";winRef.close();I get JavaScript error that this winRef do not support the close() property.Any help? Regards.AsadUllah. Link to comment Share on other sites More sharing options...
Synook Posted August 16, 2010 Share Posted August 16, 2010 The value of the myWin variable is an object, not a scalar value that can be passed through the querystring. Link to comment Share on other sites More sharing options...
jeffman Posted August 16, 2010 Share Posted August 16, 2010 We don't double-post on this forum. FYI. :)A document can close any window that it opens. When you submit your form, a new document is loaded into the browser. Because it is a new document, it does not have permission to close the other window. It does not matter that the documents are associated. Link to comment Share on other sites More sharing options...
hussainian Posted August 17, 2010 Author Share Posted August 17, 2010 The value of the myWin variable is an object, not a scalar value that can be passed through the querystring.So whats the solution then? Link to comment Share on other sites More sharing options...
hussainian Posted August 17, 2010 Author Share Posted August 17, 2010 A document can close any window that it opens. When you submit your form, a new document is loaded into the browser. Because it is a new document, it does not have permission to close the other window. It does not matter that the documents are associated.For this reason I want to use the object reference myWin passing technique to the newly loaded document. So that the child reference may be available in it and it may use it. Link to comment Share on other sites More sharing options...
jeffman Posted August 17, 2010 Share Posted August 17, 2010 I'm pretty sure the browser will not allow that. Link to comment Share on other sites More sharing options...
justsomeguy Posted August 17, 2010 Share Posted August 17, 2010 You can't pass a window reference to a new page. You can pass window references around open windows, so if your new page opens in a new window then once that's open you can pass the new page the window reference, but if you're opening a page in the same window there's no way to do that. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.