私のコードには奇妙な問題があります..私はこの基本的なコードを持っています。
<script type="text/javascript">
setTimeout(function () { myfunc('0', '0'); }, 1000);
</script>
「0」「0」の代わりに変数を使用しようとしています。これらの変数をテキスト ファイルから読み取り、それに応じてスクリプトを変更しましたが、ログ コンソールで setTimeout が以前のように呼び出されなくなっていることがわかります。何か案が?
<script type="text/javascript">
file = fopen(getScriptPath("myfile"), 0);
if (file != -1) {
file_length = flength(file);
content = fread(file, file_length);
fileLines = content.split("\n");
lines = fileLines.length;
// I skip the header lines (1 and 2)
for (i = 2; i <= lines; i++) {
chn = fileLines[i].split("_");
values = fileLines[i].split(" ");
if (values[3] == 1) {
if (chn[1] == "t1") {
var1 = values[1];
var2 = values[2];
setTimeout(function () { myfunc(var1, var2); }, 1000);
}
}
}
}
fclose(file);
// Even if I put the function here it is not called unless I comment all the rest!
//setTimeout(function() {myfunc(var1,var2);}, 1000);
</script>
myfile の構造は次のとおりです。
header1
header2
text_t1 0 0 1
text_t2 0 1 1
text_t3 0 2 1