JavaScript pop-up save file path window (XP test OK)

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.