khateeb
khateeb

Reputation: 5469

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.

Upvotes: 0

Views: 1057

Answers (1)

khateeb
khateeb

Reputation: 5469

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

Upvotes: 1

Related Questions