如何在javascript中的重定向功能中传递servlet动作 [英] how to pass servlet action in redirect function in javascript

查看:88
本文介绍了如何在javascript中的重定向功能中传递servlet动作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


在我的第一个jsp中,我弹出一个jsp窗口.在这个弹出窗口中,我选择了几个请求,并将其通过servlet传递给另一个jsp.我的问题是,当我将请求从弹出窗口传递到第二个jsp时,第二个jsp仅在同一弹出窗口中显示.我如何关闭弹出窗口并将请求传递给第二个jsp.在以下代码中,我在弹出窗口中使用了重定向功能,但它不起作用.请帮助我解决该问题....


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

推荐答案

将此JavaScript放在父窗口中.在父函数中调用此javascript函数redirect,其参数需要像redirect(selectedIds)

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

更新javascript函数重定向以接受参数

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
}

这篇关于如何在javascript中的重定向功能中传递servlet动作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆