jsexecutor class : direct JavaScript function call
Description
Calls a JavaScript function with Rice's method invocation notation.
Syntax
instance.JavaScriptFunctionName(appropriateArguments)
Arguments
You can place the arguments in the order required by the JavaScript function. These arguments should be the int, long, real, string, or bool class.
Return value
Class | Description |
string | A return value from the JavaScript function. |
Sample code
Suppose you have the following JavaScript function in currently displayed page.
1: | function square(number) { |
2: | return number * number; |
3: | } |
Let's invoke the above JavaScript function with direct JavaScript function call.
1: | jsexecutor jse; // For Main-browser |
2: | string result = jse.square(funcName, 5); // The result is '25'. |
This method call will be success though the jsexecutor class do not have the square(int) method.
Notes
You can call a JavaScript function with Rice's method invocation notation.
You can place the arguments in the order required by the JavaScript function. These arguments should be the int, long, real, string, or bool class.
Please note that the return value is string.
If the result is a number, the number will be returned as a string. Example: 1-> '1' , 1.05-> '1.05'.
If the result is a boolean value, the value is returned as a string. Example: true -> 'true' / false -> 'false'
If the result is a string, the string will be enclosed in double quotes and returned. Example: 'Returned string' -> '"Returned string"'.
If the result is null, undefined, array, object, function object, or unevaluable, the string 'null' is returned.
The 'null' is also returned if the run raises an exception.
Links for reference
None.