Eric Knudtson
Eric Knudtson

Reputation: 2563

I want HTML link to .ics file to open in calendar app when clicked, currently opens file as plain text. Suggestions?

I am linking to an .ics file exported from Apple iCal in an HTML web page.

<a href="calendar.ics">

This link will open the calendar.ics file as plain text in my browser (Chrome). I want automatic opening in Outlook or iCal or other calendar apps. What can I add to the link tag in order to produce the desired behavior? What about modifying the HTTP headers on .ics files?

Any suggestions are appreciated!

Upvotes: 30

Views: 91276

Answers (2)

Michael come lately
Michael come lately

Reputation: 9323

If your calendar file is not static, you should consider the webcal scheme in addition to setting the MIME type to text/calendar in Ryan's answer.

<a href="webcal://example.com/path/calendar.ics">

Rather than downloading a one-time file, the attendees' calendar programs will periodically poll for updates to your calendar. This will let their calendars add new events and update changed events to match your published list.

Platform and application support

Desktop

  • Calendar applications like Outlook and iCal can register with the OS to handle links with that scheme.

  • In many browsers, a specific website like Google Calendar or Outlook.com can ask to handle webcal links.

Mobile

  • iOS can import calendar events with webcal and a text/calendar type.

  • Android is an odd case:

    • Despite a merge request to add file support to AOSP, it was never put in.
    • Third party packages like ICSx5 can sign up to subscribe to a webcal and provide the events to the user's primary calendar application.

Upvotes: 35

Ryan Corbin
Ryan Corbin

Reputation: 96

If your site is built on Linux like mine you can simply add a line to your htaccess file to make it open as a download instead of a text page.

add this to your htaccess file:

AddType text/calendar .ics

Upvotes: 8

Related Questions