只要该页面是从本地文件系统加载的,此JS代码应该适用于Windows上的IE和Firefox。你需要在Linux/OSX上进行测试。我不知道你将如何接近铬/狩猎/歌剧。
function execute(command, commandParam)
{
if (isIE()) {
try {
activexShell = new ActiveXObject("Shell.Application");
activexShell.ShellExecute(command, commandParam, "", "open", "1");
exit();
} catch (e) {
alert("exception " + e.name + ': ' + e.message);
}
}
else {
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var FileFactory = new Components.Constructor("@mozilla.org/file/local;1","nsILocalFile","initWithPath");
var program = new FileFactory(command);
var process = Components.classes["@mozilla.org/process/util;1"].createInstance(Components.interfaces. nsIProcess);
process.init(program);
process.run(false, commandArray, commandParam.split(" ").length - 1, {});
exit();
} catch (e) {
alert("exception " + e.name + ': ' + e.message);
}
}
}