html、js獲取本地文件夾路徑,打開本地應用程序

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

 

<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" onclick="runExecutable()" value="打開應用程序">
</body>
</html>html

 

只能夠用IE瀏覽器打開,而且須要在工具安全中設置可以使用ActiveXObject控件java

 

方法2:利用html、angularjs和Python,在Python文件中引用import os,調用其中os.startfile(路徑)方法,就能夠打開本地文件了angularjs

方法3.利用URL Protocol實現網頁調用本地應用程序 (可ctrl+點擊查看網上相關資料):web

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

對應的程序可能連接不同,可參考http://blog.csdn.net/zssureqh/article/details/25828683這個網址。瀏覽器

相關文章
相關標籤/搜索