我在Firefox上運行此,上鍊接點擊時,火狐說NS_ERROR_FILE_UNRECOGNIZED_PATH wheread我跟着從這裏How to open .EXE with Javascript/XPCOM as Windows "Run..."?運行埃克在Firefox爲什麼我得到一個錯誤
<html>
<head>
<script>
function RunExe(path) {
try {
var ua = navigator.userAgent.toLowerCase();
if (ua.indexOf("msie") != -1) {
MyObject = new ActiveXObject("WScript.Shell")
MyObject.Run(path);
} else {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var exe = window.Components.classes['@mozilla.org/file/local;1'].createInstance(Components.interfaces.nsILocalFile);
exe.initWithPath(path);
var run = window.Components.classes['@mozilla.org/process/util;1'].createInstance(Components.interfaces.nsIProcess);
run.init(exe);
var parameters = [""];
run.run(false, parameters, parameters.length);
}
} catch (ex) {
alert(ex.toString());
}
}
</script>
</head>
<body>
<a href="#" onclick="javascript:RunExe('C:\Windows\System32\cmd.exe /c start winword.exe');">Open Word</a>
</body>
我希望這個代碼不能在任何理智的瀏覽器中工作,即使這個html存儲在本地。 – CodesInChaos
Firefox警告用戶之前:) –