폴더 선택을 하기 위한 HTML 코드 : Contents of folderDialog.html
<html> <head> <title>Browse Folders</title> <SCRIPT LANGUAGE="JavaScript"> <!-- var currentFolder=""; function GetDriveList(){ var fso, obj, n, e, item, arr=[]; try { fso = new ActiveXObject("Scripting.FileSystemObject"); } catch(er) { alert('Could not load Drives. The ActiveX control could not be started.'); cancelFolder(); }
e = new Enumerator(fso.Drives); for(;!e.atEnd();e.moveNext()){ item = e.item(); obj = {letter:"",description:""}; obj.letter = item.DriveLetter; if (item.DriveType == 3) obj.description = item.ShareName; else if (item.IsReady) obj.description = item.VolumeName; else obj.description = "[Drive not ready]"; arr[arr.length]=obj; } return(arr); } function GetSubFolderList(fld){ var e, arr=[]; var fso = new ActiveXObject("Scripting.FileSystemObject"); var f = fso.GetFolder(fld.toString()); var e = new Enumerator(f.SubFolders); for(;!e.atEnd();e.moveNext()){ arr[arr.length]=e.item().Name; } return(arr); } function loadDrives(){ var drives=GetDriveList(),list=""; for(var i=0;i<drives.length;i++){ list+="<div onclick=\"loadList('"+drives[i].letter+':\\\\\')" class="folders" onmouseover="highlight(this)" onmouseout="unhighlight(this)">'+drives[i].letter+':\\ - '+ drives[i].description+'</div>'; } document.getElementById("path").innerHTML='<a href="" onclick="loadDrives();return false" title="My Computer">My Computer</a>\\'; document.getElementById("list").innerHTML=list; currentFolder=""; } function loadList(fld){ var path="",list="",paths=fld.split("\\"); var divPath=document.getElementById("path"); var divList=document.getElementById("list"); for(var i=0;i<paths.length-1;i++){ if(i==paths.length-2){ path+=paths[i]+' \\'; }else{ path+="<a href=\"\" onclick=\"loadList('"; for(var j=0;j<i+1;j++){ path+=paths[j]+"\\\\"; } path+='\');return false">'+paths[i]+'</a> \\ '; } } divPath.innerHTML='<a href="" onclick="loadDrives();return false">My Computer</a> \\ '+path; divPath.title="My Computer\\"+paths.toString().replace(/,/g,"\\"); currentFolder=paths.toString().replace(/,/g,"\\");