javascript - 重定向父级 - 关闭弹出窗口 - ASP

标签 javascript asp.net

我需要帮助来通过单击弹出窗口中的提交按钮来重定向父页面

应该发生:

  1. 用户点击提交按钮,弹出窗口中的参数将通过 URL 传递
  2. 父页面将重定向到详细信息页面
  3. 弹出窗口已关闭

会发生什么:

  1. 用户点击提交按钮,弹出窗口中的参数将通过 URL 传递
  2. 已提交参赛作品
  3. 父级不重定向
  4. 弹出窗口被重定向

代码

ReturnValue.url = "TransDetailMain.aspx?AcctDate=" +AcctDate+ "&AcctCategoryCode=" +AcctCategoryCode+ "&DeptProfitCtr=" +DeptProfitCtr+ "&RefDocNum=" + RefDocNum + "&COMMAND=Edit&REFERRING_PAGE_KEY=MtMonthlyCatalystMain.aspx";//?AcctDate="+AcctDate;
//window.returnValue = ReturnValue;
window.location.href = ReturnValue.url;
// window.opener.location.href = ReturnValue.url;
//window.parent.location.href=ReturnValue.url;
// similar behavior as an HTTP redirect
// window.location.replace(ReturnValue.url);

问题:

  1. 用于在 Windows 2003 服务器中工作的代码
  2. 迁移到 2008 年,它不再起作用

最佳答案

我假设你正在使用 JavaScript,所以我在这里写

在这里查看我的答案 How to close current Browser window and redirect to a previously opened window for the same browser

String x = "<script type='text/javascript'>window.opener.location.href='**Your new url of new page after completing test**';self.close();</script>";
ScriptManager.RegisterClientScriptBlock(this.Page,this.Page.GetType(), "script", x,false);

它说明 self.close() 当前将被关闭,新的 url 将被打开 所以你的新代码将如下所示

现在怎么办

String x = "<script type='text/javascript'>window.opener.location.href='**TransDetailMain.aspx?AcctDate=" +AcctDate+ "&AcctCategoryCode=" +AcctCategoryCode+ "&DeptProfitCtr=" +DeptProfitCtr+ "&RefDocNum=" + RefDocNum + "&COMMAND=Edit&REFERRING_PAGE_KEY=MtMonthlyCatalystMain.aspx**';self.close();</script>";
    ScriptManager.RegisterClientScriptBlock(this.Page,this.Page.GetType(), "script", x,false);

将其放入弹出的提交点击中 所以会发生的情况是父窗口将被重定向并且当前窗口将被关闭 注意:此代码未经测试 我希望这会对您有所帮助...:)

关于javascript - 重定向父级 - 关闭弹出窗口 - ASP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19393757/

相关文章:

javascript - 不使用用户代理字符串检测 Google TV

javascript - React.js 中的 GET 请求到服务器

javascript - 在 For 循环中使用 Math.max() 时出现问题

asp.net - 您将如何通过电子邮件实现数据库更新?

javascript - Express.js + Sequelize + 表单验证

javascript - chrome 访问浏览器历史记录

asp.net - 输出缓存动态生成的CSS

c# - Ext.Net GridPanel 日期列更改默认值

asp.net - 在 IIS/.net 中伪造 Http 状态代码以进行测试

asp.net - 单击事件在 CSS 中不起作用