2

Anchor tag not downloading file in IE, instead it gives the option to search for app in app store to open file. For chrome and FF this code is working fine. I don't know this is happening in windows 7 or not as I am using windows 8.1 and windows 7 don't have option for apps.

var a = document.createElement("a");
a.href = filepath;
a.download = filename;
a.click();

Any help will be highly appreciated. Thanks.

Nadeem Shaikh
  • 362
  • 5
  • 23

2 Answers2

0

Directly quoting from SOpost

Internet Explorer does not presently support the Download attribute on A tags.

See http://caniuse.com/download and http://status.modern.ie/adownloadattribute; the latter indicates that the feature is "Under consideration" for IE12.

Community
  • 1
  • 1
stratovarius
  • 3,720
  • 1
  • 30
  • 26
0

this might help:

               var blob = new Blob([response.responseText], { type: headers['content-type'] });
            if (navigator.msSaveOrOpenBlob) {
                //Launches the associated application for a File or Blob saving for non webkit based browser such as safari or IE
                navigator.msSaveOrOpenBlob(blob, "cvSummary.xml");
            }
            else {
                //code for webkit based browser
                var link = document.createElement('a');
                document.body.appendChild(link);
                link.style = "display: none";
                var url = window.URL.createObjectURL(blob);
                link.href = window.URL.createObjectURL(blob);
                link.download = "cvSummary.xml";
                link.dataset.downloadurl = ["text/xml", link.download, link.href].join(':');
                link.click();
                window.URL.revokeObjectURL(url);
            }