I have the following code onClick of a button
$('#someForm').attr("target", "formresult");
.......
winPop = window.open("", 'formresult', 'allthesettingshereblablah');
.......
$('#someForm').submit();
everything works and a new pdf is displayed in the popup window.
I want to put in a logic like if there is already a popup open, ignore the button click... If I don't do submit, I can do winPop.closed check and it will have the correct reference.
BUT, if I have the submit(), the reference is lost...winPop.closed no longer works.
I know the reference is changed because if I put in
winPop.onbeforeunload = function() {
alert('i am closing');
};
the I am closing alert is displayed right before the pdf displays, which means that the original winPop is unloaded and I no longer have that reference.
What is the proper flow/way I should do this?
Basically I need click generate button from parent window >> submit form and opens pdf in child window >> If I click generate button from parent window again, it should ignore the click when child window is open.