Forum Moderators: open
I have a question for which I cannot find an answer and would be very grateful for some help.
I have a Java applet within an HTML page and I can call the applet's methods from JavaScript without a problem when the page is viewed in Internet Explorer 6.0. If an applet method returns any Java primitive data type then the value can be assigned to a JavaScript variable and displayed (and this is also true if the applet method returns a Java String). However, if an applet method returns a Java array then the JavaScript variable to which it is assigned is always valueless.
So, with Internet Explorer 6.0 is it actually possible to have an applet method that returns a Java array to JavaScript? If so, could someone please provide a simple example. Many thanks.
Terry.
JScript (as opp to Javascript) also doesn't seem to have the inbuilt Java interface objects.
If you can't find any "official" way, there could be a work around (or two).
1) Get your applet to output the array as a delimited string (Here I've used colons, but it could be any string), then get JS to split the string. This is only good for strings.
var output = "apple:orange:banana"
var outputArray = output.split(':');
2) Get the applet to return a string in the form of an array literal. Then eval it. This covers string, number and boolean members.
var output = "['apple',2,false]";
var outputArray = eval(output);
Terry.