只要該頁面是從本地文件系統加載的,此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);
}
}
}
當然,您可能需要簽署.js文件才能使其正常工作。欲瞭解更多信息,請看這裏:http://www.mozilla.org/projects/security/components/signed-scripts.html