必须引入
netscape.javascript.JSException
netscape.plugin.Plugin
包在jre\lib\plugin.jar里
用
用
Navigator
public
public
JSObject
}
}
在
当从
异常,这时您可以用
try
global.eval_r("foo.bar
}
if
jsCodeFailed()";
}
otherCodeFailed();
}
}
访问
我们用
允许您通过变量
public
win
myForm=win.eval_r("document.testForm")
}
您也可以用下面的语句来代替
JSObject
JSObject
如果
允许您访问它的
public
win
JSObject
JSObject
JSObject
Boolean
}
访问
在
JavaScript
JSObject.getWindow().eval_r("表达式")
###############JavaScript 中使用 Applet对象######################
<applet id = "" codebase = "." archive = "twaver.jar" code = "demo.MainFrame" width = "100%" height = "75%" align= "middle" MAYSCRIPT>
</applet>
...
<SCRIPT LANGUAGE="JavaScript">
<!--
function openURL(name){
alert("hello");
}
//Javascript operates the function 'createServer' in Applet
function createServer(name){
document.applets[0].createServer('A B C');
}
//-->
</SCRIPT>
------------------------------------------------------
import netscape.javascript.*;
public class MainFrame extends JApplet {
...
//Applet operates the function 'openURL' in Javascript
private void openURL(String name){
JSObject window = JSObject.getWindow(this);
String code = "openURL(\"" + name + "\");";
window.eval_r(code);
}
public void createServer(String name){
}Node server = new Node();
server.setName(name);
box.addElement(server);
}
...