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

Description

Creates a script tag and insert the JavaScript code.

Syntax

instance.SetJSFromFile(string path, string id)

Arguments

ClassNameDescription
stringpathPath to a JavaScript file.
stringidid attribute.

Return value

None.

Sample code

1:

window w;

2:

jsexecutor jse = w.CurrentJSExecutor;

3:

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.

Copyright © Rice All rights reserved.