Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
228 views
in Technique[技术] by (71.8m points)

java - how to pass servlet action in redirect function in javascript


in my first jsp i am poping up a jsp window. in this pop up window i am selecting few request and passing it to another jsp through servlet. my problem is while i am passing the request from pop up window to second jsp the second jsp is shown in the same pop up window only. how can i close the pop up window and pass the request to second jsp . in the following code i have used redirect function in pop up window but it is not working. please help me how to go about it....

function UpdatePannel()
{
var selectedIds;
var count=0;
for (i=0; i<document.frm1.check1.length; i++)
{
if (document.frm1.check1[i].checked==true)
{
if(count==0){
selectedIds=document.frm1.check1[i].value; 
count=count+1; 
}
else
selectedIds=selectedIds+","+document.frm1.check1[i].value;
}
}
alert(selectedIds);  

//document.frm1.action="<%=contextPath%>/AddInterviewPannel?ids="+selectedIds;
//window.close()
     //   document.frm1.submit();

     redirect();
} 

function redirect()
{
opener.location.href="<%=contextPath%>/AddInterviewPannel?ids="+selectedIds;
window.close()
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Place this javascript in parent window. call this javascript function redirect in parent function with the parameter need to passed like redirect(selectedIds)

update the javascript function redirect to accept parameter

function redirect(selectedIds){
    opener.location.href="<%=contextPath%>/AddInterviewPannel?ids="+selectedIds;
    popupobj.close() // popupobj => have the reference to popup , initialize this with return value of window.open
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...