java.lang.ObjectJSObject allows Java to manipulate objects that are defined in JavaScript. Values passed from Java to JavaScript are converted as follows:
|
+----netscape.javascript.JSObject
(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.
The netscape.javascript.JSObject class has the following static methods:
Method |
Description
getWindow
|
Gets a JSObject for the window containing the given applet
| |
---|
The following sections show the declaration and usage of these methods.
call
Method. Calls a JavaScript method. Equivalent to "this.methodName(args[0], args[1], ...)" in JavaScript.
Declaration
public Object call(String methodName,
Object args[]) eval
Method. Evaluates a JavaScript expression. The expression is a string of JavaScript source code which will be evaluated in the context given by "this".
Declaration
public Object eval(String s)
getMember
Method. Retrieves a named member of a JavaScript object. Equivalent to "this.name" in JavaScript.
Declaration
public Object getMember(String name)
getSlot
Method. Retrieves an indexed member of a JavaScript object. Equivalent to "this[index]" in JavaScript.
Declaration
public Object getSlot(int index)
getWindow
Static method. Returns a JSObject for the window containing the given applet.
Declaration
public static JSObject getWindow(Applet applet)
removeMember
Method. Removes a named member of a JavaScript object.
Declaration
public void removeMember(String name)
setMember
Method. Sets a named member of a JavaScript object. Equivalent to "this.name = value" in JavaScript.
Declaration
public void setMember(String name,
Object value) setSlot
Method. Sets an indexed member of a JavaScript object. Equivalent to "this[index] = value" in JavaScript.
Declaration
public void setSlot(int index,
Object value) toString
Method. Converts a JSObject to a String.
Overrides: toString in class Object
Declaration
public String toString()
java.lang.ObjectJSException is an exception that is thrown when JavaScript code returns an error.
|
+----java.lang.Throwable
|
+----java.lang.Exception
|
+----netscape.javascript.JSException
Constructor |
Description
JSException
|
Constructs a JSException. You specify whether the
JSException has a detail message and other information.
| |
---|
The following sections show the declaration and usage of these constructors.
JSException
Constructor. Constructs a JSException. You specify whether the JSException has a detail message and other information.
Declaration
1. public JSException()
2. public JSException(String s)
3. public JSException(String s,
String filename,
int lineno,
String source,
int tokenIndex) Arguments
s is the detail message.
filename is the URL of the file where the error occurred, if possible.
lineno is the line number if the file, if possible.
source is the string containing the JavaScript code being evaluated.
tokenIndex is the index into the source string where the error occurred.
Description
A detail message is a string that describes this particular exception.
Each form constructs a JSException with different information:
java.lang.ObjectThis class represents the Java reflection of a plug-in. Plug-ins that need to have Java methods associated with them should subclass this class and add new (possibly native) methods to it. This allows other Java entities (such as applets and JavaScript code) to manipulate the plug-in.
|
+----netscape.plugin.Plugin
Constructor |
Description
Plugin
|
Constructs a Plugin.
| |
---|
The netscape.plugin.Plugin class has the following methods:
The following sections show the declaration and usage of these constructors and methods.
destroy
Method. Called when the plug-in is destroyed. You never need to call this method directly, it is called when the plug-in is destroyed. At the point this method is called, the plug-in will still be active.
Declaration
public void destroy()
See also
init
getPeer
Method. Returns the native NPP object--the plug-in instance that is the native part of a Java Plugin object. This field is set by the system, but can be read from plug-in native methods by calling:
NPP npp = (NPP)netscape_plugin_Plugin_getPeer(env, thisPlugin);
Declaration
public int getPeer()
getWindow
Method method. Returns the JavaScript window on which the plug-in is embedded.
Declaration
public JSObject getWindow()
init
Method. Called when the plug-in is initialized. You never need to call this method directly, it is called when the plug-in is created.
Declaration
public void init()
See also
destroy
isActive
Method. Determines whether the Java reflection of a plug-in still refers to an active plug-in. Plug-in instances are destroyed whenever the page containing the plug-in is left, thereby causing the plug-in to no longer be active.
Declaration
public boolean isActive()
Plugin
Constructor. Constructs a Plugin.
Declaration
public Plugin()