iveConnect has two applet API packages: netscape.javascript and
netscape.plugin.
The netscape.javascriptapplet API package
has the following classes:
The netscape.pluginapplet API package has
the following classes:
The following sections describe these classes and list
their constructors and methods.
The public final class 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.
Values passed from JavaScript to Java are converted as
follows:
-
-
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.
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 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.
The netscape.javascript.JSObject class has the
following methods:
The netscape.javascript.JSObject class has the
following static methods:
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[index]" in JavaScript.
public Object getSlot(int index)
Static method. Returns a JSObject for the window
containing the given applet.
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[index] = 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()
The public class JSException extends
Exception.
java.lang.Object
|
+----java.lang.Throwable
|
+----java.lang.Exception
|
+----netscape.javascript.JSException
JSException is an exception that is thrown when
JavaScript code returns an error.
The netscape.javascript.JSException class has the
following constructors:
The following sections show the declaration and usage
of these constructors.
Constructor. Constructs a JSException. You specify
whether the JSException has a detail message and other information.
1. public JSException()
2. public JSException(String s)
3. public JSException(String s,
String filename,
int lineno,
String source,
int tokenIndex)
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.
A detail message is a string that describes this particular
exception.
Each form constructs a
JSException with different information:
-
-
Form 1 of the declaration constructs a JSException without a detail
message.
-
Form 2 of the declaration constructs a JSException with a detail message.
-
Form 3 of the declaration constructs a JSException with a detail message
and all the other information that usually comes with a JavaScript error.
The public class Plugin extends
Object.
java.lang.Object
|
+----netscape.plugin.Plugin
This 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.
The netscape.plugin.Plugin class has the following
constructors:
The netscape.plugin.Plugin class has the following
methods:
The following sections show the declaration and usage
of these constructors and methods.
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.
public void destroy()
init
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);
public int getPeer()
Method method. Returns the JavaScript window on which
the plug-in is embedded.
public JSObject getWindow()
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.
public void init()
destroy
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.
public boolean isActive()
Constructor. Constructs a Plugin.
public Plugin()
file: /Techref/language/java/script/packages.htm,
21KB, , updated: 2009年2月2日 14:27, local time: 2025年9月12日 10:05,
©2025 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Questions?<A HREF="http://techref.massmind.org/Techref/language/java/script/packages.htm"> The Netscape packages </A>
Did you find what you needed?
Welcome to massmind.org!
Welcome to techref.massmind.org!
.