最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - TypeError: Object doesn't support this action in IE 11 - Stack Overflow

programmeradmin0浏览0评论

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"});

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"});

Share Improve this question edited Dec 19, 2017 at 7:07 its.me.chand asked Dec 19, 2017 at 6:35 its.me.chandits.me.chand 951 gold badge1 silver badge9 bronze badges 3
  • Try including the following script <!--[if IE]> <script src="cdnjs.cloudflare./ajax/libs/html5shiv/3.7.3/…> <![endif]--> – Deepak Kumar T P Commented Dec 19, 2017 at 6:39
  • it is not working – its.me.chand Commented Dec 19, 2017 at 6:59
  • Related post - IE11 JavaScript (Error: SCRIPT445) “Object doesn't support this action” – RBT Commented Feb 3, 2020 at 12:45
Add a ment  | 

1 Answer 1

Reset to default 5

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.

发布评论

评论列表(0)

  1. 暂无评论