JS Operation IE Browser pop-up Browse folder can return directory path _javascript tips

Source: Internet
Author: User

As shown in the figure:

You can return a directory path.

The operation is as follows:

function Browsefolder () { 
try{ 
var message = "Please select folder";//selection box hint info 
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 ();//Return Folderitems object 
folder = Folder.item ();//Back to Fol Deritem Object 
folder = Folder.path//return path 
if (Folder.charat (folder.length-1)!= "\") { 
folder = folder + "\" ; 
} 
return Folder; 
} 
return null; 
} catch (e) { 
alert ("Please enable the Acitvex control related options in the IE settings. "); 
return null; 
} 
}
var Folder = Browsefolder ();

Here This folder is the path that is returned after the selection directory is determined.

Suppose I selected the Works directory on E disk, the return value is E:\works\

Note: Sometimes you may be prompted with no permissions and so on, because it is a client-side JS operation, so you need to enable some of the ActiveX options in the security customization of the Internet option.

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.