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

前端 未结 3 436
日久生厌
日久生厌 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条回答
  •  旧时难觅i
    2021-01-01 02:54

    Answering my own question:

    The problem was not in the .ics output itself, rather it was in IE and Opera not treating the js-generated output as a file to download. To enforce such a download, is only possible from a server-side script.

    I ended up recoding my logic to output the .ics file on the server-side, and by enforcing these headers:

    header('Content-type: text/calendar; charset=utf-8');
    header('Content-Disposition: attachment; filename=cal.ics');
    

    It was a painful restructuring, but now it works across browsers.

提交回复
热议问题