【发布时间】:2015-07-30 21:40:02
【问题描述】:
全部,
我有一个 java 脚本文件,它打开一个记事本文件但出现未定义对象错误。我觉得这与安全有关,但不确定.. 可以请教吗?
注意:单击按钮时调用运行函数。 错误:未捕获的 ReferenceError:未定义 ActiveXObject 在 IE 中 - 我能够收到警报 4,但看不到记事本,但在 Chrome 中只能卡在警报 1。
<script language="JavaScript" type="text/javascript">
function run() {
alert("step 1");
var oShell;
oShell = new ActiveXObject("Shell.Application");
alert("step 2");
var commandtoRun = "c:\\windows\\system32\\notepad.exe";
alert("step 3");
oShell.ShellExecute(commandtoRun, "", "", "open", "1");
alert("step 4");
}
</script>
【问题讨论】:
-
在Microsoft's own documentation
Creating an ActiveXObject on a remote server is not supported in Internet Explorer 9 standards mode, Internet Explorer 10 standards mode, Internet Explorer 11 standards mode, and Windows Store apps or later. -
在 Chrome 中 - 因为其他浏览器不支持 ActiveXObject,您会卡在 alert1 上。
在 IE 中 - 你卡在 alert4 - 因为你的浏览器没有运行 exe 的权限。您收到权限被拒绝错误。