Created
December 20, 2010 20:28
-
-
Save unscriptable/748930 to your computer and use it in GitHub Desktop.
How to communicate between javascript and java applet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var myApplet = funcToGetApplet(); | |
| myApplet.setCallback({ | |
| myMethod: function (args) { | |
| // do something with args here | |
| }, | |
| anotherMethod: function (args) { | |
| // do something with args here | |
| } | |
| }); | |
| // in the applet: | |
| public void setCallback (JSObject cbObj) { | |
| this.cbObj = cbObj; | |
| } | |
| public void callMyMethod (arg1, arg2, arg3) { | |
| Object[] args = { arg1, arg2, arg3 }; | |
| this.cbObj.call("myMethod", args); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment