1

Well, this is my trouble:

I have an applet that controlls a magnetic stripe reader and I need to call a JS function when the MSR reads a card to catch the data and submit in a form. The problem is the applet cannot call JS functions when it is called from a remote PC o server, but locally all the code works fine. I supposed that is a issue of privileges on the browser. This is my HTML code:

<html>
<head>
    <title>Applet Prueba</title>
    <script src="jquery-1.7.1.min.js" type="text/javascript"></script>
    <script type="text/javascript">
    $(document).ready(function()
    {
        $("#AppletPrueba")[0].apOpenPrinter();
        $("#AppletPrueba")[0].apActivaMSR();
    });

    function print()
    {
        $("#AppletPrueba")[0].apPrintCreditInfo();
    }

    function setTxtBox(texto)
    {
        $("#txtBox").val(texto);
    }
    </script>
</head>
<body>
    <object id      = "AppletPrueba"
            classid = "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
            width   = "1"
            height  = "1">
        <param name="code" value="applet.AppletJPos.class"/>
        <param name="archive" value="SAppletJPos.jar,Sjpos11021.jar,Sjpos191.jar,SNCRJavaPOS39.jar,SNCRJavaPOSClasses.jar,Sxerces.jar"/>
        <param name="scriptable" value="true"/>
        <param name="mayscript" value="true"/>
        <param name="param0" value="1"/>
        <param name="param1" value="Tienda"/>
        <param name="param2" value="XXX"/>
        <param name="param3" value="RUBEN C. FLORES GARNETT"/>
        <param name="param4" value="09 de Marzo de 2012"/>
        <param name="param5" value="0.00"/>
        <param name="param6" value="0.00"/>
        <param name="param7" value="0.00"/>
        <param name="param8" value="0.00"/>
        <param name="param9" value="0.00"/>
        <param name="param10" value="0.00"/>
        <param name="param11" value="0"/>
        <param name="param12" value="0.00"/>
        <param name="param13" value="0.00"/>
        <param name="param14" value="0.00"/>
        <param name="param15" value="0.00"/>
        <param name="param16" value="0.00"/>
        <param name="param17" value="0.00"/>
        <param name="param18" value="0.00"/>
        <param name="param19" value="0.00"/>
        <param name="param20" value="0.00"/>
        <param name="param21" value="0.00"/>
        <param name="param22" value="0.00"/>
        <param name="param23" value="0.00"/>
        <param name="param24" value="1"/>
    </object>
    <input type="button" value="Imprime Ticket" onclick="print()" />
    <br/>
    <input type="text" value="" id="txtBox" />
</body>

And that is the way the applet call the JS function:

AppletContext appletCtxt = getAppletContext();

...

appletCtxt.showDocument(new URL("javascript: setTxtBox('" + editedCardId[0] + "')"));

I really hope somebody can help me.

(I'm sorry if my english is bad :P)

1 Answer 1

1

The Oracle tutorial on the matter would probably be useful.

Invoking JavaScript Code From an Applet

The netscape.javascript.JSObject class enables Java applets to retrieve a reference to JavaScript objects and interact with the web page.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.