jsexecutor class : SetJSFromFile(string,string) method
Description
Creates a script tag and insert the JavaScript code.
Syntax
instance.SetJSFromFile(string path, string id)
Arguments
Class | Name | Description |
string | path | Path to a JavaScript file. |
string | id | id attribute. |
Return value
None.
Sample code
1: | jsexecutor jse; // For Main-browser |
2: | jse.SetJSFromFile("c:\appropriate\path\sample.js", "smple"); // It creates a script tag has JS code and id. |
Supposes "c:\appropriate\path\sample.js" has JavaScriopt code as follows.
1: | function hello(){ |
2: | alert('hello world!'); |
3: | } |
The following script tag is added to the body tag.
1: | <script id="sample"> |
2: | function hello(){ |
3: | alert('hello world!'); |
4: | } |
5: | </script> |
Notes
Reads the JavaScript code from the first argument file and writes it to the script tag.
If the file is empty, an exception, RtypeException, will occur.
If the file does not exist, an exception, UnknownException, will occur.
Links for reference
None.