简体   繁体   中英

How to put default file extension in save as dialog using javascript?

When I clicked on asp:button , it will prompt a save as dialog box. But I want to put default extension.

 function Open() {
        // var open = document.getElementById('<%=btnGenerate.ClientID %>>').click();
        var obj = document.getElementById('<%=rbtGenerateinpage.ClientID %>');
       // var path = "C:\Users\karthik.mushyam\Downloads";
        if (obj.checked == true) {
            window.open("WebForm1.aspx", "Page", "menubar=no, status=no, scrollbars=no, menubar=no, width=900, height=600");
        }   
        else {
            document.execCommand("SaveAs", true);
        }    
    }

Can anyone suggest me how can I put this .default extension to be .sql

Assuming your issue with with the "SaveAs" command, the third parameter to execCommand is the name of the file to be saved as in:

document.execCommand("SaveAs", true, "myfile.sql");

Details are on this MSDN page .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM