JSFiddle - React, Tailwind, and code Playground

HTML

<body>

<p>Click the button to write some text in the new window and the source (parent) window.</p>

<button onclick="myFunction()">Try it</button>

<script>
function myFunction() {

    var windowWidth = 250;
    var windowHeight = 100;
    var locX = (screen.width - 150 - windowWidth) / 2;
    var locY = (screen.height - 50 - windowHeight) / 2;
    var windowFeatures = "width=" + windowWidth + ",height=" + windowHeight + ",screenX=" + locX + ",screenY=" + locY + ",left=" + locX + ",top=" + locY;


    if ((winConfirm != null) && !winConfirm.closed) {
		somethingChosen=true;
        winConfirm.close();
    }

    var winConfirm =  window.open("menubar = no", "winConfirm", windowFeatures);
    var theHTML = '' + '<BODY BGCOLOR="#DDDDDD"  onunload="opener.childClosed()">' + 
	'<CENTER><B><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#FF0000">' + 'Please choose ?' + '</B></CENTER><FORM NAME="buttonForm"><BR/>'+
     '<TABLE BORDER="0" WIDTH="100%" CELLPADDING="0" CELLSPACING="0">'+
     '<TR>'+
     '<TD width="40" ALIGN="CENTER"> &nbsp;</TD>'+
     '<TD>' + '<INPUT TYPE="button" NAME="buttonname" VALUE="YES" STYLE="WIDTH:60;HEIGHT:30;FONT-WEIGHT:BOLD;" ONCLICK="self.close();opener.buttonClicked(0);">' + '&nbsp;' + '</TD>'+
     '<TD ALIGN="CENTER"><INPUT TYPE="button"  NAME="buttonname" VALUE="NO" STYLE="WIDTH:60;HEIGHT:30;FONT-WEIGHT:BOLD;"  ONCLICK="self.close();opener.buttonClicked(1);">' + '</TD>'+
     '<TD WIDTH="40"> &nbsp; </TD>'+
     '</TR></TABLE></FORM></BODY>';

    winConfirm.document.writeln(theHTML);
	somethingChosen=false;
} 
var somethingChosen=false; //rename the flag as per like
 function childClosed(){
		if(!somethingChosen) myFunction(); // or however else you want to handle it
 }
function buttonClicked(buttonChoice) {
    var CONTACT_ID = "<%=CONTACT_ID%>";
	somethingChosen=true;
    switch (buttonChoice) {
        case 0:
            console.log('yes');
            break;
        case 1:
            console.log('no');
...