Passing javascript callback for java applet deployed using deployJava

I have an applet that runs for quite some time, but which is necessary for my application to work.

I used to register javascript callback: jsAppletIsStarted. This callback was called at the end of the applet launch method.

The code looked something like this:

<script>
var jsAppletIsStarted = function(){/*do some useful stuff*/};
</script>
<applet id=".." etc>
<param name="appletStartedCallBack" value="jsAppletIsStarted "/>
</applet>

And it worked like a charm.

I had to switch to another way to launch the applet: using the deployJava.runApplet () method.

Now the code is as follows:

    <script>
    var jsAppletIsStarted = function(){/*do some useful stuff*/};

    var attributes = {};

 attributes.code = "myAppletClass.class";
 attributes.codebase="myCodeBase";

 var parameters = {};
 parameters.appletStartedCallBack="jsAppletIsStarted " ;

 var version = '1.6' ;
 deployJava.runApplet(attributes, parameters, version);
   </script>

And the callback is no longer recognized. In my java console, I have the following error.

12:26:24,655 ERROR  com.mypackage.JavaScriptCallBack     - 
netscape.javascript.JSException: No such method "jsAppletIsStarted" on JavaScript object 
netscape.javascript.JSException: No such method "jsAppletIsStarted" on JavaScript object      
at sun.plugin2.main.client.MessagePassingJSObject.newJSException(Unknown Source)  at 
sun.plugin2.main.client.MessagePassingJSObject.waitForReply(Unknown Source)  at 
sun.plugin2.main.client.MessagePassingJSObject.call(Unknown Source)  at 
com.mypackage.JavaScriptCallBack.callJsCallBack(JavaScriptCallBack.java:131) 
com.myapplet.MyApplet.start(MyApplet.java:662) at 
sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)  at 
java.lang.Thread.run(Unknown Source)

Is there a hack for passing javascript callbacks as applet parameters for use with deployJava.js?

+3
1

.

getAppletContext().showDocument(new URL("javascript:jsAppletIsStarted()"));
0

Source: https://habr.com/ru/post/1776679/


All Articles