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

回眸只為那壹抹淺笑 提交于 2019-11-27 00:30:34

问题


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!


回答1:


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



回答2:


If your calendar file is not static, you should consider the webcal:// protocol which Outlook and iCal will handle:

<a href="webcal://domain.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.



来源:https://stackoverflow.com/questions/5329529/i-want-html-link-to-ics-file-to-open-in-calendar-app-when-clicked-currently-op

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!