0

so I have a Java Applet and I want to pass a string within the Java Applet to Javascript, how do you do this? Is it even possible? I tried searching google but it only showed examples of passing a JS string to Java, not Java to JS, the String is in a method

public String calc(String ans2)

Please help me as I need to pass the String to Javascript so I can edit it further using html codes, Thanks

2
  • Can you make a request from JS to the server and get the variable? Commented Feb 12, 2012 at 15:48
  • It's not on a server, the variable is a String, and is called 'ans' if that helps, I have tried function getJavaString() { str = binomial.Main.calc(ans); alert(str); } Commented Feb 12, 2012 at 15:51

2 Answers 2

1

See Call Javascript from a Java applet. It shows 2 techniques for an applet to use/call JS methods. The 2nd, using JSObject, is probably the more reliable way to do it.

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

Comments

0

yes, you can but you have to make sure the html object tag is setup right as well as both your Java and JavaScript code.

Here's an overview: http://www.raditha.com/java/javascript.php

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.