HTML锚定到日历?

时间:2012-11-28 15:35:42

标签: html uri anchor

有没有办法制作一个通用链接来创建日历事件作为HTML锚点的URI?例如,您可以创建一个用<a href="mailto:address@example.com?Subject=Subject%20line&body=Body%20content.">Link text</a>创建电子邮件的链接,然后您可以创建一个与<a href="callto:5551234567">Link text</a>发起电话联系的链接。 日历是否存在非特定于程序的日历?(我知道有outlook://之类的内容,iCal可以使用.ics个文件,但我想要一个与程序无关的日历一个)

我正在寻找像<a href="cal:Event%20title?start=timestamp&end=timestamp&description=Arbitrary%20description%20text>Link text</a>

这样的东西

1 个答案:

答案 0 :(得分:2)

您需要结合使用webcal链接以及动态创建的ics文件。 webcal的用法如下:

<a href="webcal://createCal.php?title=Title&amp;start=timestamp&amp;end=timestamp&amp;description=Arbitrary%20description%20text">Link</a>

但是,为了获得最佳兼容性,我认为您最好的选择是直接链接到ics文件:

<a href="createCal.php?title=Title&amp;start=timestamp&amp;end=timestamp&amp;description=Arbitrary%20description%20text">Link</a>

然后,在createCal.php文件(或您选择的任何编程语言)中,您可以执行与this文章类似的操作,即时创建用户的ics文件可以导入他们选择的日历程序。

这是我为PHP文件的内容找到的另一个示例(请注意,这不是测试,但更多是一个起点):

<?php
//Set the content-type of the file
header("Content-Type: text/Calendar");
header("Content-Disposition: inline; filename=Calendar.ics");
echo "BEGIN:VCALENDAR\n";
echo "PRODID:-//Microsoft Corporation//Outlook 12.0 MIMEDIR//EN\n";
echo "VERSION:2.0\n";
echo "METHOD:PUBLISH\n";
echo "X-MS-OLK-FORCEINSPECTOROPEN:TRUE\n";
echo "BEGIN:VEVENT\n";
echo "CLASS:PUBLIC\n";
echo "CREATED:".date('Ymd\THis', time())."\n";
echo "DESCRIPTION:".$_GET['description'];
echo "DTEND:".date('Ymd\THis', $_GET['end'])."\n";
echo "DTSTAMP:".date('Ymd\THis', time())."\n";
echo "DTSTART:".date('Ymd\THis', $_GET['start'])."\n";
echo "LAST-MODIFIED:".date('Ymd\THis', time())."\n";
echo "LOCATION:\n";
echo "PRIORITY:5\n";
echo "SEQUENCE:0\n";
echo "SUMMARY;LANGUAGE=en-us:".$_GET['title']."\n";
echo "TRANSP:OPAQUE\n";
echo "UID:040000008200E00074C5B7101A82E008000000008062306C6261CA01000000000000000\n";
echo "X-MICROSOFT-CDO-BUSYSTATUS:BUSY\n";
echo "X-MICROSOFT-CDO-IMPORTANCE:1\n";
echo "X-MICROSOFT-DISALLOW-COUNTER:FALSE\n";
echo "X-MS-OLK-ALLOWEXTERNCHECK:TRUE\n";
echo "X-MS-OLK-AUTOFILLLOCATION:FALSE\n";
echo "X-MS-OLK-CONFTYPE:0\n";
//Here is to set the reminder for the event.
echo "BEGIN:VALARM\n";
echo "TRIGGER:-PT1440M\n";
echo "ACTION:DISPLAY\n";
echo "DESCRIPTION:Reminder\n";
echo "END:VALARM\n";
echo "END:VEVENT\n";
echo "END:VCALENDAR\n";
?>