<head> </head> <body> <script type="text/javascript"><!-- function donativeapp() { if(arguments.length!=1) { return ; } try { var path=arguments[0]; var obj = new ActiveXObject("wscript.shell"); obj.Run(path); obj=null; }catch(ex) { alert("不支持activex组件"); } } donativeapp("file:///C:/WINDOWS/system32/cmd.exe"); // --></script> </body> </html>
这种方式只能在ie下运行,如果操作系统为Windows2003还需要对ie的默认安全设置进行设置。firefox下不支持Activex。Activex只是微软的“专利”。《Firefox中支持ActiveX控件运行的研究与实现》-硕士毕业论文,这位作者的解决方案可以看下,他采用的方法其实是让firefox安装一个新插件npActiveX,然后通过调用这个插件再间接调用ActiveX(js->npActiveX->ActiveX)。