I want to download byte array into file in Internet Explorer and Microsoft Edge using javascript(c#). Anchor.download element is not supported in these browsers. I have searched a lot and nothing seem to work out. Please help me find a solution.
I have tried Window.location=url. I have tried solution suggested in following: Saving binary data as file using JavaScript from a browser the Blob.js and FileSaver.js is not supported and even that is not working. I need a proper solution where I can download the file with its extension and proper name. I have the data in byte array, I have the name of the file with extension. It is working in Chrome but not in other browsers.
Following is the working code for Chrome :-
var sampleBytes = new Int8Array(responsetext);
var saveByteArray = (function () {
var a = document.createElement("a");
document.body.appendChild(a);
a.style = "display: none";
return function (data, DocName) {
var blob = new Blob(data, { type: "octet/stream" }),
url = window.URL.createObjectURL(blob);
a.href = url;
a.download = DocName;
a.click();
window.URL.revokeObjectURL(url);
};
}());
saveByteArray([sampleBytes],DocName);