Javascript-generated .ics file opens in Chrome and Firefox, but not in IE

前端 未结 3 438
日久生厌
日久生厌 2021-01-01 02:18

I\'m generating a .ics calendar entry from JS, next I open it using a data-URI:

window.open(\"data:text/calendar;charset=utf8,\" + escape(icsMSG));
         


        
3条回答
  •  再見小時候
    2021-01-01 02:46

    It appears there is a way to do this without using a server-side script. I answered a similar Stack Overflow question when I found this snippet that worked for me in the github issues for react-add-to-calendar:

    var blob = new Blob([icsMSG], { type: 'text/calendar;charset=utf-8' });
    window.navigator.msSaveOrOpenBlob(blob, 'download.ics');
    

    This is working for me in Internet Explorer 11 without having to use a server to download the file.

提交回复
热议问题