復制代碼 代碼如下:
function BrowseFolder(){
try{
var Message = "請選擇文件夾"; //選擇框提示信息
var Shell = new ActiveXObject( "Shell.Application" );
var Folder = Shell.BrowseForFolder(0,Message,0x0040,0x11);//起始目錄為:我的電腦
//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.all.savePath.value=Folder;
return Folder;
}
}catch(e){
//alert(e.message);
}
}