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:
JavaScript | Java |
---|---|
boolean primitive | java.lang.Boolean |
number primitive | java.lang.Double |
string primitive | java.lang.String |
JavaObject object | The encapsulated Java object unwrapped |
all other JavaScript objects | netscape.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.
Prev | Home | Next |
JSObject.call() | Up | JSObject.getMember() |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |