carlsednaoui / add-to-calendar-buttons

Easily add a "add to calendar" button to your websites. This JavaScript library supports Google Calendar, iCal, Outlook and Yahoo Calendar.
476 stars 171 forks source link

iCal and Outlook calendar don't work in any version of IE... #7

Closed im1dermike closed 9 years ago

im1dermike commented 9 years ago

The subject says it all. Clicking on either link only opens a data:text/calendar link that can't be resolved. I'm using IE10 and all the other github issues are for previous version of IE. Has there been any resolution?

im1dermike commented 9 years ago

I stumbled upon these SO posts which seem to indicate you'll never be able to open an ICS file in IE (or Opera) via javascript...

http://stackoverflow.com/questions/21938890/javascript-generated-ics-file-opens-in-chrome-and-firefox-but-not-in-ie

http://stackoverflow.com/questions/16566300/internet-explorer-8-and-vcalendar-ics-files

im1dermike commented 9 years ago

I came up with a work around. I changed the href on a.icon-outlook and a.icon-ical to point to a method on my controller in IE only. I pass the encoded calendar entry in the query string of the request. Then my server side method adds the code to the response.

    public void GenerateCalendarEntry(string calendarEntry)
    {
        HttpContext.Response.ContentType = "text/calendar";
        HttpContext.Response.AddHeader("Content-disposition", "attachment; filename=appointment.ics");
        HttpContext.Response.Write(calendarEntry);
        HttpContext.Response.End();
    }