js選擇目錄

來源:互聯網
上載者:User

標籤:style   blog   http   ar   io   color   os   sp   for   

找了好久,終於找到了!function browseFolder(path) {//開啟本地目錄(目錄選擇功能)                try {                   var Message = "\u8bf7\u9009\u62e9\u6587\u4ef6\u5939"; //選擇框提示資訊                   var Shell = new ActiveXObject("Shell.Application");                   var Folder = Shell.BrowseForFolder(0, Message, 64, 17); //起始目錄為:我的電腦                   //var Folder = Shell.BrowseForFolder(0, Message, 0); //起始目錄為:案頭                   if (Folder != null) {                       Folder = Folder.items(); // 返回 FolderItems 對象                                   Folder = Folder.item(); // 返回 Folderitem 對象                                   Folder = Folder.Path; // 返迴路徑                                   if (Folder.charAt(Folder.length - 1) != "\\") {                                       Folder = Folder + "\\";                                   }                                   document.getElementById(path).value = Folder;                                   return Folder;                               }                           }                   catch (e) {                       alert(e.message);                   }               }        <tr>            <td>選擇匯入資料來源:</td>            <t<d><input id="path" type="text" name="path" size="30"></td>            <td><input type=button value="選擇" onclick="browseFolder(‘path‘)"></td>        </tr>

如果點擊選擇按鈕提示:你沒有許可權,應該如下修改:首先將檔案加入java Web 專案中去
    1. 單擊菜單工具->Internet選項->安全->受信任網站->網站->把此網站設為可信網站
    2. 在自訂層級->對沒有標記為安全的ActiveX控制項進行初始化和指令碼運行"----"啟用"


 

缺點:此js只能用於ie瀏覽器


 

 

js選擇目錄

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.