开发者

how to pass servlet action in redirect function in javascript

开发者 https://www.devze.com 2023-03-01 11:19 出处:网络
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 w

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?i开发者_JAVA技巧ds="+selectedIds;
window.close()
}


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
}


popup.html

<html> 
<head> 
</head> 
<body> 
<a href="#" onclick="window.opener.location.href='new.htm';">change parent</a> 
</body> 
</html>

parent.html

<html> 
<head> 
</head> 
<body> 
<a href="#" onclick="window.open('popup.html','kid','resizable=no,scrollbars=no,width=250,height=148,toolbar=no');">click</a> 
</body> 
</html>

Its working fine for me.. Compare your code and find out the reason.

0

精彩评论

暂无评论...
验证码 换一张
取 消