【问题标题】:After closing popup window next page is opening in new tab关闭弹出窗口后,下一页将在新选项卡中打开
【发布时间】:2013-12-03 22:26:37
【问题描述】:

在我的代码中,我需要打开一个弹出窗口,其中将进行一些工作。然后,从父页面我将恢复工作。问题是,每当我单击任何按钮时关闭弹出窗口后,下一页都会在新选项卡中打开。我在父页面中调用弹窗的代码如下:

document.auctionForm.action = "/getAcceptance.do";
popup = window.open('', 'view','top=0, left=350, height=500, width=600, toolbar=no, status=no');
document.auctionForm.target = 'view';
document.auctionForm.submit();

当我不打开弹出窗口直接转到下一页时,不会出现此问题。我尝试通过如下方式在关闭弹出窗口时刷新父页面来修复它,但这每次都有效,并且必须手动刷新页面,这是不可接受的。

window.onunload = refreshParent;
function refreshParent() {
document.auctionForm.target = window.parent;
window.opener.location.reload();
} 

我正在使用 struts1。

【问题讨论】:

  • 你能把你的代码放到 jsfiddle 里,让我们看看吗?
  • 我该怎么做?我正在使用 struts1。

标签: javascript jquery html popup struts


【解决方案1】:

我通过在提交后将目标更改回父窗口来解决它:

document.auctionForm.action = "/getAcceptance.do";
popup = window.open('', 'view','top=0, left=350, height=500, width=600, toolbar=no, status=no');
document.auctionForm.target = 'view';
document.auctionForm.submit();    
document.auctionForm.target = "_parent";

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-07-31
    • 2011-04-16
    • 1970-01-01
    • 2010-09-07
    • 1970-01-01
    • 1970-01-01
    • 2012-06-03
    • 1970-01-01
    相关资源
    最近更新 更多