Class JSObject
- netscape.javascript.JSObject
public abstract class JSObject extends Object
Allows Java code to manipulate JavaScript objects.
When a JavaScript object is passed or returned to Java code, it is wrapped in an instance of JSObject. When a JSObject instance is passed to the JavaScript engine, it is unwrapped back to its original JavaScript object. The JSObject class provides a way to invoke JavaScript methods and examine JavaScript properties.
Any data returned from the JavaScript engine to Java is converted to Java data types. Certain data passed to the JavaScript engine is converted to JavaScript data types. See the section on Data Type Conversions in the new LiveConnect Specification for details on how values are converted.
-
Constructor Summary
Constructors Modifier Constructor and Description protectedJSObject()Constructs a new JSObject.
-
Method Summary
All MethodsStatic MethodsInstance MethodsAbstract MethodsConcrete Methods Modifier and Type Method and Description abstract Objectcall(String methodName, Object... args)Calls a JavaScript method.abstract Objecteval(String s)Evaluates a JavaScript expression.abstract ObjectgetMember(String name)Retrieves a named member of a JavaScript object.abstract ObjectgetSlot(int index)Retrieves an indexed member of a JavaScript object.static JSObjectgetWindow(Applet applet)Returns a JSObject for the window containing the given applet.abstract voidremoveMember(String name)Removes a named member of a JavaScript object.abstract voidsetMember(String name, Object value)Sets a named member of a JavaScript object.abstract voidsetSlot(int index, Object value)Sets an indexed member of a JavaScript object.
-
Constructor Detail
-
JSObject
protected JSObject()
Constructs a new JSObject. Users should not call this method nor subclass JSObject.
-
-
Method Detail
-
call
public abstract Object call(String methodName, Object... args) throws JSExceptionCalls a JavaScript method. Equivalent to "this.methodName(args[0], args[1], ...)" in JavaScript.
Parameters:
methodName- The name of the JavaScript method to be invoked.Returns:
Result of the method.
Throws:
-
eval
public abstract Object eval(String s) throws JSExceptionEvaluates a JavaScript expression. The expression is a string of JavaScript source code which will be evaluated in the context given by "this".
Parameters:
s- The JavaScript expression.Returns:
Result of the JavaScript evaluation.
Throws:
-
getMember
public abstract Object getMember(String name) throws JSExceptionRetrieves a named member of a JavaScript object. Equivalent to "this.name" in JavaScript.
Parameters:
name- The name of the JavaScript property to be accessed.Returns:
The value of the propery.
Throws:
-
setMember
public abstract void setMember(String name, Object value) throws JSExceptionSets a named member of a JavaScript object. Equivalent to "this.name = value" in JavaScript.
Parameters:
name- The name of the JavaScript property to be accessed.Throws:
-
removeMember
public abstract void removeMember(String name) throws JSExceptionRemoves a named member of a JavaScript object. Equivalent to "delete this.name" in JavaScript.
Parameters:
name- The name of the JavaScript property to be removed.Throws:
-
getSlot
public abstract Object getSlot(int index) throws JSExceptionRetrieves an indexed member of a JavaScript object. Equivalent to "this[index]" in JavaScript.
Parameters:
index- The index of the array to be accessed.Returns:
The value of the indexed member.
Throws:
-
setSlot
public abstract void setSlot(int index, Object value) throws JSExceptionSets an indexed member of a JavaScript object. Equivalent to "this[index] = value" in JavaScript.
Parameters:
index- The index of the array to be accessed.Throws:
-
getWindow
public static JSObject getWindow(Applet applet) throws JSExceptionReturns a JSObject for the window containing the given applet.
Parameters:
applet- The applet.Returns:
JSObject for the window containing the given applet.
Throws:
-
© 2008, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from JavaFX API Documentation.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Java, JavaFX and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.