JSObject.eval() (Java method)

A means of invoking native JavaScript eval() functionality.

Availability:

JavaScript - 1.1
Netscape - 3.0
Java syntax:myJSObject.eval("someScript")
Argument list:someScriptSome valid JavaScript source

This is a much simpler way to execute JavaScript than by the call() method. Here there is no need to construct an array to pass in the method arguments.

The return values will conform to the following conversions as they are passed between the environments:

JavaScriptJava
boolean primitivejava.lang.Boolean
number primitivejava.lang.Double
string primitivejava.lang.String
JavaObject objectThe encapsulated Java object unwrapped
all other JavaScript objectsnetscape.javascript.JSObject

The JSObject.eval() method eliminates many of the parameter passing problems associated with the JSObject.call() method as far as type conversion is concerned. You will need to convert any parameters you want to pass into strings, but this does allow you to pass primitive values which you simply cannot do with the JSObject.call() method.

See also:Eval code, eval(), JavaScript to Java values, JSObject object, JSObject.call(), LiveConnect