简体   繁体   English

关闭弹出窗口后,下一页将在新标签页中打开

[英]After closing popup window next page is opening in new tab

In my code, I need to open a popup window in which some work will take place. 在我的代码中,我需要打开一个弹出窗口,其中将进行一些工作。 Then, the from the parent page I will resume working. 然后,从父页面开始,我将继续工作。 The problem is that after closing the popup window whenever I am clicking on any button the next page is opening in a new tab. 问题在于,每当我单击任意按钮时,关闭弹出窗口后,下一页就会在新选项卡中打开。 My code for calling the popup in the parent page is as below: 我在父页面中调用弹出窗口的代码如下:

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

This problem is not occurring when I directly go to the next page without the opening the popup. 当我直接打开下一页而不打开弹出窗口时,不会发生此问题。 I tried fixing it by refreshing the parent page on the closing of the popup window as below but this does work every time and the page has to be manually refreshed and that is not acceptable. 我尝试通过在弹出窗口关闭时刷新父页面来修复它,如下所示,但这每次都有效,并且必须手动刷新页面,这是不可接受的。

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

I am using struts1. 我正在使用struts1。

I solved it by changing the target back to the parent window after the submit: 我通过在提交后将目标更改回父窗口来解决它:

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";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM