网页中调用本地EXE程序 ActiveX .

字体大小: 中小 标准 ->行高大小: 标准
IE 浏览器 
[javascript] 
1. <a href="javascript:LaunchApp()">Click here to Execute your file</a>  
2.<script>  
3.function LaunchApp() {  
4.    if (!document.all) {  
5.        alert ("This ActiveXObject is only available for Internet Explorer");  
6.        return;  
7.    }  
8.  
9.    var ws = new ActiveXObject("WScript.Shell");  
10.    ws.Exec("D:\\yourfile.exe");  
11.}  
12.</script>  
 <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 浏览器

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

此文章由 http://www.ositren.com 收集整理 ,地址为: http://www.ositren.com/htmls/67606.html