Javascript中打开文件对话框

打开对换诓:
try{
var fd = new ActiveXObject("MSComDlg.CommonDialog");
        fd.Filter = "Text Files (*.txt)|*.txt";
        fd.FilterIndex = 2;      
        // 必须设置MaxFileSize. 否则出错
        fd.MaxFileSize = 128;
        fd.ShowOpen();
        return fd.filename;
}catch(e){return "";}
保存对话框:
var fd = new ActiveXObject("MSComDlg.CommonDialog");
        fd.Filter = "Text Files (*.txt)|*.txt";
        fd.FilterIndex = 2; 
        //必须设置MaxFileSize. 否则出错
        fd.MaxFileSize = 128;
        fd.ShowSave();
        if(fd.filename=="" || fd.filename.length<1)return false;

====================
方法 所显示的对话框 
ShowOpen 显示“打开”对话框 
ShowSave 显示“另存为”对话框 
ShowColor 显示“颜色”对话框 
ShowFont 显示“字体”对话框 
ShowPrinter 显示“打印”或“打印选项”对话框 
ShowHelp 调用 Windows 帮助引擎

你可能感兴趣的:(JavaScript,windows)