As shown in the figure:
You can return the directory path.
The operation is as follows:
function BrowseFolder(){ try{ var Message = "Please select folder"; //Select box prompt message 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(); // Return Folderitem object Folder = Folder.Path; // Return path if(Folder.charAt(Folder.length-1) != "//"){ Folder = Folder + "//"; } return Folder; } return null; } catch(e){ alert("Please enable the related options of the AcitveX control in the ie settings."); return null; } }var Folder = BrowseFolder();Here, this Folder is the path returned after selecting the directory and determining it.
Assuming that I select the works directory of E disk, the return value is E:/works/
Note: Sometimes you may prompt that there is no permission or something. Because it is a client js operation, some options of ActiveX need to be enabled in the security customization of Internet options.