教程·Javascript 中文手册
The public final class JSObject extends Object.
java.lang.Object
|
+----netscape.javascript.JSObjectJSObject allows Java to manipulate objects that are defined in JavaScript. Values passed from Java to JavaScript are converted as follows:
Values passed from JavaScript to Java are converted as follows:
This means that all JavaScript values show up as some kind of java.lang.Object in Java. In order to make much use of them, you will have to cast them to the appropriate subclass of Object, as shown in the following示例:
(String) window.getMember("name")
(JSObject) window.getMember("document")
Note
表 14.1 Methods for the JSObject class
The netscape.javascript.JSObject class has the following static methods:表 14.2 Static methods for the JSObject class
| Method | 描述 |
|---|---|
| Gets a JSObject for the window containing the given applet |
The following sections show the declaration and usage of these methods.
Method. Calls a JavaScript method. Equivalent to "this.methodName(args[0], args[1], ...)" in JavaScript.
public Object call(String methodName,
Object args[])
Method. Evaluates a JavaScript expression. The expression is a string of JavaScript source code which will be evaluated in the context given by "this".
public Object eval(String s)
Method. Retrieves a named member of a JavaScript object. Equivalent to "this.name" in JavaScript.
public Object getMember(String name)
Method. Retrieves an indexed member of a JavaScript object. Equivalent to "this【索引】" in JavaScript.
public Object getSlot(int index)
Static method. Returns a JSObject for the window containing the given applet. This method is available only on the client.
public static JSObject getWindow(Applet applet)
Method. Removes a named member of a JavaScript object.
public void removeMember(String name)
Method. Sets a named member of a JavaScript object. Equivalent to "this.name = value" in JavaScript.
public void setMember(String name,
Object value)
Method. Sets an indexed member of a JavaScript object. Equivalent to "this【索引】 = value" in JavaScript.
public void setSlot(int index,
Object value)
Method. Converts a JSObject to a String.
Overrides: toString in class Object
public String toString()