“Save as”-button in IE, save file on client side

Is there any way to make a button that generates a text/xml file, sets the content-type to application-download, adds an attachment etc on the client side? What i want is a “download”-button on my page that saves an xml-file. This is how i do the same thing on serverside:

response.StatusCode = 200;
        response.ContentEncoding = Encoding.UTF32;
        response.AddHeader("content-disposition", "attachment; filename=" + fileName);
        response.AddHeader("Content-Transfer-Encoding", "binary");
        response.AddHeader("Content-Length", response.ContentEncoding.GetByteCount(xmlString).ToString());
        response.ContentType = "application-download";

  • jquery - select an element with specific content
  • text-overflow ellipsis without “white-space: nowrap”?
  • Text within circle div. Div size adjusted to content
  • How do I insert html code using ng-repeat in AngularJS?
  • Prevent # anchor in an iframe from scrolling the browser window
  • Javascript global onclick listener
  • How to detect when a page exits fullscreen?
  • How do I install/use the backbone.js framework?
  • how to display the links in tabs in bootstrap?
  • Toggle class from dropdown menu
  • How to select all text in contenteditable div?
  • Could we replace images with srcset?
  • One Solution collect form web for ““Save as”-button in IE, save file on client side”

    If you mean to create the file in jQuery/Javascript and be able to save it to disk from the browser, the answer is plain NO. Javascript is not allowed (for security reasons) to save to disk, neither to make the browser throw a “Save as…” popup for something locally created.
    You have an easier solution to your question. In your example you are creating the xml file and sending it as an attachment from the server, why dont you just make a button to download the file created by the server?
    You can’t do it by plain ajax, cause it can’t trigger downloads in the browser, but you can use the old “iframe download trick” to launch the download in the same page.

    function download(url_to_your_creating_file_servlet){
    iframe = document.createElement('iframe');  
    iframe.style.visibility = 'hidden';
    iframe.src = url_to_your_creating_file_servlet;

    Or if you don’t mind to open another window/tab (a bit uglier) this also works:

    <a href="url_to_your_creating_file_servlet" target="blank"> Download </a>