I'm looking at the "Sample Web Browser Program" from the ACUCOBOL 9.2.2 "Programmer's Guide to the Internet". It compiles and works, but now I'd like to extend it with some event-driven interactions between JavaScript, VBScript, and COBOL.
Assume the following HTML5 document:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8">
<title>HTML5 JavaScript VBScript Example</title>
<script type="text/vbscript"> Function vbFunction() document.write("vbFunction has been called") End Function </script> <script type="text/javascript"> function jsFunction() { document.write("jsFunction has been called") } </script> </head>
</body>
</body>
</html>
After the HTML5 page shown above has been loaded into the WEB-BROWSER control, is it possible for COBOL code to call the VBScript and JavaScript functions (vbFunction and jsFunction)?
A C# example that shows how it might be done in a pure .NET application is here:
Microsoft's C# example relies on the ObjectForScripting property of the .NET Framework;s WebBrowser class. But I don't see any equivalent property exposed in AcuBench for the WEB-BROWSER control.
A related question is, how might JavaScript or VBScript that's running in the WEB-BROWSER control trigger an event that could then be handled by COBOL code? Say for example I wanted to do the following:
- User clicks a button with an onclick attribute that specifies a JavaScript function (function1).
- The JavaScript function raises some event (for example by changing the value of the <title> element?)
- A COBOL procedure "somehow" handles the event, and reads a record from a Vision file
- The COBOL procedure calls another JavaScript function (function2), passing the value of a COBOL field as a parameter
The point of this approach would be to allow the user interface to be written entirely in HTML5 JavaScript and/or VBScript, while the COBOL program containing the WEB-BROWSER control would handle the IO with Vision files that reside in the Windows filesystem.
Any advice would be appreciated!
#JavaScript
#VBScript
#acubench
#ACUCOBOL9.2.1
#web-browser
#Events