jsexecutor クラス : SetJSFromFile(string,string)メソッド
説明
script タグを作成し、JavaScript コードを挿入します。
構文
instance.SetJSFromFile(string path, string id)
引数
| クラス | 名前 | 説明 |
| string | path | JavaScript ファイルのパス。 |
| string | id | id 属性。 |
返り値
無し。
サンプルコード
| 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. |
"c:\appropriate\path\sample.js"が以下の様な JavaScriopt コードを持つとします。
| 1: | function hello(){ |
| 2: | alert('hello world!'); |
| 3: | } |
以下の様な script タグが body タグに追加されます。
| 1: | <script id="sample"> |
| 2: | function hello(){ |
| 3: | alert('hello world!'); |
| 4: | } |
| 5: | </script> |
注意
第一引数のファイルから JavaScript コードを読み込んで script タグに書き出します。
ファイルが空ファイルの場合は例外(RtypeException)が発生します。
ファイルが存在しない場合は例外(UnknownException)が発生します。
参照リンク
無し。


