Home News DOC Class DL Others Rice
Class  >  jsexecutor  >  Execute(string)
jsexecutor class : Execute(string) method

Description

Executes JavaScript code.

Syntax

instance.Execute(string jscode)

Arguments

ClassNameDescription
stringjscodeJavaScript code.

Return value

ClassDescription
stringReturn value from the JavaScript.

Sample code

1:

window w;

2:

jsexecutor jse = w.CurrentJSExecutor;

3:

string result = jse.Execute("alert('hello world!');"); // It show dialog and return "null".

Notes

The JavaScript code is complemented to the immediate function and executed. For example

return 'result'; -> (function (){return 'result';}());


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.

Copyright © Rice All rights reserved.