javascript读取java变量
import java.awt.*; import java.applet.*; public class InJava3 extends Applet{ public int iJava = 123; public String sJava = "String from JAVA"; public int getIntJava() { return iJava; } public String getStringJava() { return sJava; } }
javascript代码
<HTML><HEAD></HEAD><BODY> <SCRIPT> function JavaSays() { alert("Java says\n the value of iJava is :" + document.myApplet.getIntJava() + "\n" + "and sJava is :" + document.myApplet.getStringJava()); } </SCRIPT> <FORM> <INPUT type="button" value="Java says" onClick = "JavaSays();"> </FORM> <APPLET CODE="InJava3.class" NAME="myApplet" HEIGHT=0 WIDTH=0> </APPLET></BODY></HTML>