12/03/28 22:53:20.90
<test1.js>
var paths = ['c:\\Program Files\\Microsoft Office\\OFFICE11\\EXCEL.EXE',
'c:\\Windows\\notepad.exe'];
<test2.js>
function run(pathw) {
var wshshell = new ActiveXObject("WScript.Shell");
wshshell.run(pathw);
}
<test3.js>
function loop(wsc){
for (var j = 0; j < wsc.length; j++){
document.write('<input type="button" value="' + j + '" onclick="run(wsc[' + j + '])">');
}
}
<main.html>
var sc;
sc = paths;
loop(sc);
for(var i=0;i<paths.length;i++){
paths[i] = '"' + paths[i] + '"';
document.write('<input type="button" value="test" onclick="run(paths[' + i + '])">');
}
と書いた場合、最後のhtml内に直接書いたfor~のrun()はうまく動きますが、
外部ファイルに切り出したloop()から呼ばれるrun()は動作しない理由はどこにあるんでしょうか??
ieのF12で見れるソースを見ると、
ともにhtmlの<inputタグは全く同じように展開されていて、問題ないように見えるのですが・・・