This involves html and javascript, although a cgi exe produced with Pure Basic is involved.
I start with a parent page, page1.html (see code below). Click on Popup and the popup window appears with a list of numbers. Click on a number then Submit. The output appears in the popup, but I would like the popup to close and the output to appear as the next page in the parent tab. I can successfully transfer a choice from the popup to the parent but in this case I would like a new page generated. I have also tried using fetch to run the exe but that has not worked, either.
Ms Google has not been helpful. I am doing this with basic CGI using html and javascript only. I am using the IIS webserver with a virtual directory set to handle CGI. Other apps are working fine.
Thanks.
Code: Select all
<!-- This is the start window opened in the browser. Click on Popup. It opens the popup window and fills it with popup.html -->
<html>
<head>
<title>Popup test</title>
</head>
<script language='javascript' type='text/javascript'>
function popupwindow(url, windowName, w, h) {
const x = window.top.outerWidth / 2 + window.top.screenX - ( w / 2);
const y = window.top.outerHeight / 2 + window.top.screenY - ( h / 2);
window.open(url,windowName,'width='+w+',height='+h+',top='+y+',left='+x+'');
}
</script>
<script language='javascript' type='text/javascript'>
async function dopopup() {
popupwindow('popup.html', 'Level', 200, 300);
}
</script>
<body>
Click below to trigger popup window<br>
<br>
<button id='levelbtn'>Popup</button>
<script language="javascript" type="text/javascript">
document.getElementById("levelbtn").addEventListener("click", dopopup);
</script>
</body>
</html>
Code: Select all
<!-- This is the popup.html code. It calls an exe compiled with PureBasic. -->
<html>
<head>
<title>Popup</title>
<style type=text/css>
.a11 {font-family:arial;font-size:11pt;font-weight:normal;color:#000000;}
.button {width:75px;height:23px;}
</style>
</head>
<body>
<script language='javascript' type='text/javascript'>
function doSubmit() {
var doc = window.opener.document,
theForm = doc.getElementById("theForm"),
theForm.submit();
window.close();
}
</script>
<form id='theForm' action='popuptest.exe' method='get'>
<p class='a11'>Choose:</p>
<Select name='List' id='List' size='10' style='width:180;' class='a11' ondblclick='doSubmit()'>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
</Select>
<br>
<br>
<input type='submit' name='send' value='Submit' onClick='doSubmit()'>
<button class='button' onclick='javascript:window.close()'>Cancel</button>
</form>
</body>
</html>
Code: Select all
;This is the cgi exe called by the popup. It makes a page that is to appear in the parent tab, not the popup
;PopupTest.pb
;Compile as PopupTest.exe
If Not InitCGI() Or Not ReadCGI()
End
EndIf
a$=CGIVariable(#PB_CGI_QueryString)
i$="<html>"+#CRLF$
i$+"<head>"+#CRLF$
i$+"<title>Popup next page</title>"+#CRLF$
i$+"<body>"+#CRLF$
i$+"Here is the next page!<br><br>"+#CRLF$
i$+a$
i$+"</body>"+#CRLF$
i$+"</html>"+#CRLF$
;CreateFile(0,"d:\bmv10\test.html")
;WriteStringN(0,i$)
;CloseFile(0)
WriteCGIHeader(#PB_CGI_HeaderContentType, "text/html", #PB_CGI_LastHeader)
WriteCGIString(i$)
End