Using JavaScript in the same HTML file as Reflection

In this example, JavaScript is used to interact with an IBM 3270 applet embedded in the browser window, where both the applet and the JavaScript code are in the same HTML file. Comments in the JavaScript explain the action. Also see the example of using JavaScript in a different HTML file than Reflection.

To use this example, you must change the hostURL parameter in the <applet> tag below to a host appropriate for your network.

<html>
<head>
<title>API Sample: JavaScript in the Same HTML File as Reflection</title>
</head>
<body>

<!--
   The <applet> tag defines a simple Reflection applet for
   IBM 3270 emulation. To use this example, change the hostURL
   parameter to one appropriate for your network.
-->
<applet mayscript name="IBM3270Applet"
        codebase="./ex/"
        code="com.wrq.rweb.Launcher.class"
        width="800" height="500"
        archive="Launcher.jar">
    <param name="hostURL" value="tn3270://payroll">
    <param name="autoconnect" value="true">
    <param name="frame" value="false">
    <param name="launcher.sessions" value="IBM3270">
    <param name="preloadJSAPI" value="true">
</applet> 
<!-- 
   <Form> buttons give the user access to the Color Setup and
   Button Palette Setup dialog boxes. The onClick event handler
   is used to invoke the API methods without requiring separate
   JavaScript functions. The Reflection applet is referenced
   on the page using the same name as defined above in the <applet> tag.
-->
<form>
<input type="button" Name="ColorSetup" Value="Color Setup"
       onClick='document.IBM3270Applet.getAPI("JSAPI","IBM3270").showDialog( "colorConfigure" )'>
<input type="button" Name="ButtonPalette" Value="Button Palette Setup"
       onClick='document.IBM3270Applet.getAPI("JSAPI","IBM3270").showDialog( "buttonPaletteConfigure" )'>
</form>
</body>
</html>