Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError: Object doesn't support this action in IE 11

This is working fine in google chrome but getting error in internet explorer at below mentioned line in my code. Can anyone suggest what change do i need to make to it to work in IE.

var file = new File([JSON.stringify($localStorage)], "somefile.txt", {type: "text/plain;charset=utf-8"});

like image 721
its.me.chand Avatar asked Dec 19 '17 06:12

its.me.chand


1 Answers

Link to original answer

To paraphrase the link, IE 11 does NOT support new File() constructor, so you'll have to use a blob instead. Here is a basic example:

var myArr = ["Hello", "World", "123", "Howdy"];
var b = new Blob([JSON.stringify(myArr)], {type: "text/plain;charset=utf-8"});
window.navigator.msSaveBlob(b, "OutputFile.txt");

And now you should receive a download prompt.

like image 154
Sal Alturaigi Avatar answered Oct 21 '22 01:10

Sal Alturaigi