Home Cooker Classes Others Rice
Classes  >  jsexecutor  >  CallJSFunc(string,...)
jsexecutor class : CallJSFunc(string,...) method

Description

Invokes a JavaScript function by its name.

Syntax

jsexecutorInstance.CallJSFunc(string funcName, ...)

Arguments

ClassNameDescription
stringfuncNameA JavaScript function name.
...Arguments passed to the JavaScript function.

Return value

ClassDescription
real,string, or boolA 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:

}

Usage of the CallJSFunc(string,...) method is as follows.

1:

jsexecutor jse = new jsexecutor();

2:

string funcName = "square";

3:

real result = jse.CallJSFunc(funcName, 5); // The return value is the real class, and its value is 25.

Notes

First argument should specify only a JavaScript function name. In the above case, the first argument is "square".

You can place the arguments required by the JavaScript function to the second and subsequent arguments. These arguments should be the int, long, real, string, or bool class.

There is no limit the number of second and subsequent arguments. You can place the arguments in the order required by the JavaScript function.


If the return value from the JavaScript function is a number, the return class will be real class.

If the return value from the JavaScript function is a string, the return class is string class.

If the return value from the JavaScript function is a boolean, the return class will be bool class.

Otherwise, the return class will be void class.

Links for reference

None.

Copyright © Rice All rights reserved.