JS operation IE Browser popup browse folder

Source: Internet
Author: User

:

You can return a directory path.

The operation is as follows:

function Browsefolder () {try{  var Message = "Please select folder";  Select box hint information  var Shell = new ActiveXObject ("Shell.Application");  var folder = Shell.browseforfolder (0,message,0x0040,0x11);//The Starting directory is: My Computer  //var Folder = Shell.browseforfolder (0, message,0); The starting directory is: Desktop  if (folder! = null) {folder = Folder.items ();  Returns the Folderitems object Folder = Folder.item ();  Returns the FolderItem object Folder = Folder.path;   Returns the path if (Folder.charat (folder.length-1)! = "\ \") {  folder = folder + "\ \";} return Folder;  }  return null; }catch (e) {alert ("Enable Acitvex control-related options in IE settings.) "); return null;}}
var Folder = Browsefolder ();

This folder here is the path returned after the selection of the directory is determined.

If I select the Works directory with the E drive, the return value is E:\works\

Note: Sometimes you may be prompted to do not have permissions and so on, because it is the client JS operation, so you need to be in the security customization of Internet options to enable some of the ActiveX options.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.