html、js获取本地文件夹路径,打开本地应用程序

方法1:<html>
<head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 </head>
<body>
<form class="form-horizontal">

 

<script type="text/javascript">
function runExecutable()
 {
   var executableFullPath=document.getElementById("path").value;
   try {
         var shellActiveXObject = new ActiveXObject("WScript.Shell");
        if ( !shellActiveXObject )
        {
          alert('Could not get reference to WScript.Shell');
          return;
         }  
          shellActiveXObject.Run(executableFullPath, 1, false);
          shellActiveXObject = null;
        }
     catch (errorObject)
     {
      alert('Error:\n' + errorObject.message);
      }
}
 
</script>
<td>
<input type="file" webkitdirectory id="path">
</td>
<input type="button" οnclick="runExecutable()" value="打开应用程序">
</body>
</html>

 

只可以用IE浏览器打开,并且需要在工具安全中设置可使用ActiveXObject控件

 

方法2:利用html、angularjs和Python,在Python文件中引用import os,调用其中os.startfile(路径)方法,就可以打开本地文件了

方法3.利用URL Protocol实现网页调用本地应用程序 (可ctrl+点击查看网上相关资料):

        我直接用的  <a href="打开的exe://cid:110&amp;username:xxh"><input value="打开本地应用程序" οnclick="document.getElementById('light2').style.display='none'" type="button"></a>

对应的程序可能链接不一样,可参考http://blog.csdn.net/zssureqh/article/details/25828683这个网址。

转载于:https://my.oschina.net/lccchn/blog/760641

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值