网页中调用本地EXE程序 ActiveX

IE 浏览器
 <a href="javascript:LaunchApp()">Click here to Execute your file</a>
<script>
function LaunchApp() {
    if (!document.all) {
        alert ("This ActiveXObject is only available for Internet Explorer");
        return;
    }

    var ws = new ActiveXObject("WScript.Shell");
    ws.Exec("D:\\yourfile.exe");
}
</script>


Firefox 浏览器

<a href="javascript:LaunchApp()">Click here to Execute your file</a>
<script>
function LaunchApp() {
    netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
    var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
    file.initWithPath("D:\\yourfile.exe");
    file.launch();
}
</script>


 

你可能感兴趣的:(JavaScript,浏览器,File,IE,exe,internet)