In the open save file dialog box, you can use the MSComDlg. CommonDialog object and set the type filter. However, you must set the MaxFileSize attribute. Otherwise, an error occurs. The specific implementation code is as follows.
It can be used in ie5678 after testing. in the XP system. new ActiveXObject ("MSComDlg. commonDialog ") object cannot be created. I found a lot of information and it seems that it still cannot be solved. we recommend that you use the file control.
If any expert has more convenient solutions, I hope you can give me some advice !!!
1 <script>
2 function SaveAs (){
3 var fd = new ActiveXObject ("MSComDlg. CommonDialog ");
4 fd. Filter = "All Files (*.*)";
5 fd. FilterIndex = 2;
6 // fd. filter = "upload a file (*. jpg ;*. jpeg ;*. gif) | *. jpg ;*. jpeg ;*. gif "; // fd. filter = "Microsoft Office Excel (*. xls) | *. xsl; | Microsoft Office Word (*. doc) | *. doc; "; filter file types
7 // you must set MaxFileSize. Otherwise, an error occurs.
8 fd. Max filesize = 128;
9
10 // display dialog box
11 fd. ShowSave ();
12 alert (fd. FileName );
13}
14 </script>
15
16 <body>
17 <form>
18 <a href = "" onclick = "SaveAs ()"> test </a>
19 </form>
20 </body>
Method dialog box
Show open dialog box
The "Save as" dialog box is displayed in ShowSave.
ShowColor display "color" dialog box
ShowFont display "font" dialog box
ShowPrinter displays the "print" or "Print Options" dialog box
ShowHelp calls Windows Help Engine