JSObject
extends Object
.java.lang.Object
|
+----netscape.javascript.JSObject
JSObject
allows Java to manipulate objects that are defined in JavaScript. Values passed from Java to JavaScript are converted as follows:![]() | JSObject is converted to the original JavaScript object. |
![]() | Any other Java object is converted to a JavaScript wrapper, which can be used to access methods and fields of the Java object. Converting this wrapper to a string will call the toString method on the original object, converting to a number will call the floatValue method if possible and fail otherwise. Converting to a boolean will try to call the booleanValue method in the same way. |
![]() | Java arrays are wrapped with a JavaScript object that understands array.length and array[index] . |
![]() | A Java boolean is converted to a JavaScript boolean. |
![]() | Java byte, char, short, int, long, float, and double are converted to JavaScript numbers. |
![]() | Objects that are wrappers around Java objects are unwrapped. |
![]() | Other objects are wrapped with a JSObject . |
![]() | Strings, numbers, and booleans are converted to String, Float, and Boolean objects respectively. |
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 examples:(String) window.getMember("name")
(JSObject) window.getMember("document")
Note If you call a Java method from JavaScript, this conversion happens automatically--you can pass in "int" argument and it works.
netscape.javascript.JSObject
class has the following methods:
Table 14.1 Methods for the JSObject
class
The netscape.javascript.JSObject
class has the following static methods:
Table 14.2 Static methods for the JSObject
class
Method | Description |
---|---|
|
Gets a JSObject for the window containing the given applet
|
The following sections show the declaration and usage of these methods.
this.methodName(args[0], args[1], ...)
" in JavaScript.public Object call(String methodName,
Object args[])
public Object eval(String s)
this.name
" in JavaScript.public Object getMember(String name)
this[index]
" in JavaScript.public Object getSlot(int index)
JSObject
for the window containing the given applet. This method is available only on the client.public static JSObject getWindow(Applet applet)
public void removeMember(String name)
this.name = value
" in JavaScript.public void setMember(String name,
Object value)
this[index] = value
" in JavaScript.public void setSlot(int index,
Object value)
JSObject
to a String
.
Overrides: toString
in class Object
public String toString()
Last Updated: 10/31/97 12:34:01