Skip to content

Javascript doesn’t download file

In Chrome downloads the ICS file, but in MS Edge, it’s trying to open the file in a different tab. How do I ensure Edge downloads the file in the same way Chrome does.


var icsMSG = ""; // Here goes the calendar details"data:text/calendar;charset=utf8," + escape(icsMSG))


Are you using Edge Legacy? Edge Legacy only support msSaveBlob method to download files. You can update your Edge to the latest Edge Chromium to make download or use msSaveBlob in Edge Legacy.

If you still want to use Edge Legacy, you can refer to the following code to use msSaveBlob to download:

    var icsMSG = ""; // Here goes the calendar details
    if (window.navigator && window.navigator.msSaveBlob) { // For IE & Edge Legacy
        var blob = new Blob([icsMSG], { type: 'text/calendar;charset=utf-8'' })
        window.navigator.msSaveBlob(blob, 'download.ics')
    else {"data:text/calendar;charset=utf8," + escape(icsMSG));