Sending/returning a string from a Java Applet to JavaScript

B

Bary W Pollack

Is it possible to have a Java Applet that is running on a web page to send/return a string (or an int) so that some JavaScript that is running on the same webpage can retrieve the information? If so, HOW?

Thanks!

-Bary-
 
L

Laurent Bugnion, GalaSoft

G

George Maydwell

Is it possible to have a Java Applet that is running on a web page to send/return a string (or an int) so that some JavaScript that is running on the same webpage can retrieve the information? If so, HOW?

Thanks!

-Bary-

This is very easy to do. The Java applet needs a public method which
returns a String and all Javascript has to do is call it. Here's The
Modern CA Author Javascript which does this in a setting with frames
where the applet may not even exist:
var mutatedRule = 'Press the "Test CA" button first'
var d = parent.frames["view"].document
var applet = d.applets[0]
if (applet) {
mutatedRule = applet.getRuleCurrentMutation()
}

Here's what the Java method looks like:
public synchronized String getRuleCurrentMutation() {
return RuleExport.toString(rule, rule.mutated != null ?
rule.mutated : rule.unmutated);
}


George Maydwell
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,077
Messages
2,570,569
Members
47,205
Latest member
KelleM857

Latest Threads

Top