1

Go figure, I am having issues with IE and was hoping someone might be able to help.... I have a site where visitors will come and sign up for a specific meeting and then I want to be able to generate an appointment for the calendar of their choice; the choices are gmail, yahoo, and outlook. The gmail and yahoo appointments are generated as expected in all browsers, but the outlook appointments work in every browser except IE. Instead of throwing a file save dialog, IE opens a new window and attempts to navigate the url.

I am using the iCalendar jquery library that I modified a bit and building the ics markup in javascript, like this

//build ics markup
var event = makeAppointment(settings);
//render ics markup as outlook appointment
window.open("data:text/calendar;charset=utf8," + escape(event));

function makeAppointment()
{
    return 'BEGIN:VCALENDAR\n' +
    'VERSION:2.0\n' +
    'PRODID:jquery.icalendar\n' +
    'METHOD:PUBLISH\n' +
    'BEGIN:VEVENT\n' +
    'UID:' + new Date().getTime() + '@' +
    (window.location.href.replace(/^[^\/]*\/\/([^\/]*)\/.*$/, '$1') || 'localhost')       + '\n' +
    'DTSTAMP:' + $.icalendar.formatDateTime(new Date()) + '\n' +
    (event.url ? limit75('URL:' + event.url) + '\n' : '') +
    (event.contact ? limit75('MAILTO:' + event.contact) + '\n' : '') +
    limit75('TITLE:' + event.title) + '\n' +
    'DTSTART:' + $.icalendar.formatDateTime(event.start) + '\n' +
    'DTEND:' + $.icalendar.formatDateTime(event.end) + '\n' +
    (event.summary ? limit75('SUMMARY:' + event.summary) + '\n' : '') +
    (event.description ? limit75('DESCRIPTION:' + event.description) + '\n' : '') +
    (event.location ? limit75('LOCATION:' + event.location) + '\n' : '') +
    (event.recurrence ? makeRecurrence(event.recurrence) + '\n' : '') +
    'END:VEVENT\n' +
    'END:VCALENDAR';
}
Greg Sipes
  • 683
  • 6
  • 16

1 Answers1

0

You can get the file save dialog to work in IE by adding a "Content-Disposition: attachment" response header. However, this must happen on the server and cannot happen in client-side scripting, since JavaScript cannot modify header information.

See this answer for related details.

Community
  • 1
  • 1
E. Barnes
  • 179
  • 7
  • Thank you! Changed the code around and everything seems to be working great.Dynamic content can be appended to the response on the server, so no need to try and do it in javascript anyways...http://www.west-wind.com/weblog/posts/2007/May/21/Downloading-a-File-with-a-Save-As-Dialog-in-ASPNET – Greg Sipes Apr 26 '12 at 16:49