JAVASCRIPT调用JAVA
类别: JAVA教程
//*********java.htm************
<HTML><HEAD></HEAD><BODY>
<SCRIPT>
function getScreenDimension() {
document.myApplet.sayHello();
}
</SCRIPT>
<FORM>
<INPUT type="button" value="call JAVA"
onClick = "getScreenDimension()">
</FORM>
<APPLET CODE="inJava.class"
NAME="myApplet"
HEIGHT=100 WIDTH=100>
</APPLET>
</BODY></HTML>
//*********inJava.java***********
import java.awt.*;
import java.applet.*;
public class inJava extends Applet{
public void sayHello() {
Graphics g = getGraphics();
g.drawString("Hello from JAVA!", 10, 10);
}
}
<HTML><HEAD></HEAD><BODY>
<SCRIPT>
function getScreenDimension() {
document.myApplet.sayHello();
}
</SCRIPT>
<FORM>
<INPUT type="button" value="call JAVA"
onClick = "getScreenDimension()">
</FORM>
<APPLET CODE="inJava.class"
NAME="myApplet"
HEIGHT=100 WIDTH=100>
</APPLET>
</BODY></HTML>
//*********inJava.java***********
import java.awt.*;
import java.applet.*;
public class inJava extends Applet{
public void sayHello() {
Graphics g = getGraphics();
g.drawString("Hello from JAVA!", 10, 10);
}
}
-= 资 源 教 程 =-
文 章 搜 索