jasonsalzman / react-add-to-calendar

A simple, customizable, and reusable Add to Calendar button component for React
https://jasonsalzman.github.io/react-add-to-calendar/
MIT License
180 stars 124 forks source link

.ics file is not getting downloaded in internet explorer 11 #4

Closed ghost closed 7 years ago

ghost commented 7 years ago

Although it is working fine in chrome

ghost commented 7 years ago
 key: 'handleDropdownLinkClick',
        value: function handleDropdownLinkClick(e) {
            e.preventDefault();
            var url = e.currentTarget.getAttribute('href');             
            if (this.state.isCrappyIE && ****(e.currentTarget.getAttribute('class') === 'ical-link' || e.currentTarget.getAttribute('class') === 'outlook-calendar-link'))**** {            
                var blob = new Blob([url], { type: 'text/calendar' });
                window.navigator.msSaveOrOpenBlob(blob, 'download.ics');
            } else {
                window.open(url, '_blank');
            }

            this.toggleCalendarDropdown();
      }

i think attributes enclosed in **** are not required, when i am removing them, i am able to download the file in ie as well

jasonsalzman commented 7 years ago

Sorry for the delayed response.

Thank you for bringing this to my attention. The latest build 0.0.8 fixes the problem. This has been released to NPM. Please let me know if you should have further issues.

jimmysolanki commented 6 years ago
function _getUrl_ics(data) {
    var startTime = formatTime(data[Count].Days);

    url = encodeURI(
    'data:text/calendar;charset=utf8,' + [
      'BEGIN:VCALENDAR',
      'VERSION:2.0',
      'BEGIN:VEVENT',
      'URL:' + document.URL,
      'DTSTART:' + (startTime),
      'DTEND:' + (startTime),
      'SUMMARY:' + (data[Count].TaskName || ''),
      'DESCRIPTION:' + (''),
      'LOCATION:' + (''),
      'END:VEVENT',
      'END:VCALENDAR'].join('\n'));
    var IsIE = false;
    if ((navigator.userAgent.indexOf("MSIE") != -1) || (!!document.documentMode == true)) //IF IE > 10
    {
        IsIE = true;
    }
    if (IsIE) {

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

    }
    Count = Count + 1;

}

it is not working for me. Help someone