Saving file on IE11 with FileSaver

I have found a workaround that works on IE11.

This is the code:

try {
            var file = new File(['content'], fileName, { type: 'application/xml;charset=utf-8' });
            saveAs(file);
} catch (err) {
            var textFileAsBlob = new Blob(['content'], { type: 'application/xml' });
            window.navigator.msSaveBlob(textFileAsBlob, fileName);
}

I hope this will help somebody, working with IE11 consumes time for little thing like this.


http://caniuse.com/#search=file [2] Some browser don't support the File constructor.

The only way you can get a File instance is through input[type=file]

instead of wrapping it around a try/catch why not just do this:

var blob = new Blob(['content'], { type: 'application/xml' });
saveAs(blob, fileName);