日期:2014-05-16  浏览次数:20294 次

JS 弹出文件保存窗口


?

//JS 弹出文件保存窗口

function BrowseFolder() {
    var mypath = window.location.href;
    alert("当前地址为:" + mypath);
	
    var saveFolder="";
    var Message = "请选择保存目录"; 
    var Shell  = new ActiveXObject("Shell.Application");
    var Folder = Shell.BrowseForFolder(0,Message,0x0000,0);
    if(Folder !=null)
    {
       if(Folder == "桌面")
       {
          saveFolder = new ActiveXObject("wscript.shell").SpecialFolders("Desktop");
       }
        else
       {
          Folder = Folder?Folder.items().item().Path:'';
          saveFolder = (/^\w:/.test(Folder))?Folder:'';
       }
       saveFolder.replace("%20"," ")//把路径中的20%还原为空格"" 
       alert("您保存路径为:" + saveFolder);
    }

    return saveFolder;
 }