jsexecutor class : ExecuteFromFile(string) method
Description
Executes JavaScript code.
Syntax
instance.ExecuteFromFile(string path)
Arguments
Class | Name | Description |
string | path | The path to the JavaScript file. |
Return value
Class | Description |
string | Return value from the JavaScript. |
Sample code
1: | jsexecutor jse; // For Main-browser |
2: | string result = jse.ExecuteFromFile("c:\appropriate\path\sample.js"); |
Notes
Loads and executes JavaScript code from a file.
The JavaScript code is complemented to the Immediately Invoked Function Expression, IIFE, and executed. For example
return 'result'; -> (function (token){return 'result';}("0f8fbd59d9cb769fa16570867728950e"));
For the method of IIFE, Please refer to Execution of JavaScript code: IIFE.
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.