Frage

I'm trying to dynamically generate a vCal file using Javascript and everything is working fine until i try in IE8. In IE8 the browser tries to open the calendar file in the request bar instead of downloading. This is a sample of the code i use

var iCal = 
    "BEGIN:VCALENDAR\n" +
    "PRODID:-//Microsoft Corporation//Outlook 14.0 MIMEDIR//EN\n" +
    "METHOD:PUBLISH\n" +
    "BEGIN:VEVENT\n" +
    "ATTENDEE;CN=\""+locationAlias+"\";CUTYPE=RESOURCE;ROLE=NON-PARTICIPANT;RSVP=TRUE:mailto:"+locationEmail+"\n" +
    "DTEND;TZID=\"GMT Standard Time\":"+dend+"\n" +
    "DTSTART;TZID=\"GMT Standard Time\":"+dstart+"\n" +
    "LOCATION:"+locationName+"\n" +
    "ORGANIZER;CN=\"<someuser>\":mailto:<somemailto>\n" +
    "END:VEVENT\n" +
    "END:VCALENDAR";

return iCal;

I then try to open the calendar file using the following;

window.open( "data:text/calendar;charset=utf8," + escape( iCal) );

Any suggestions as to why IE8 cannot recognize the file?

War es hilfreich?

Lösung

To get around this problem i generated the iCal file one the server side and exposed to the Client via a RESTful webservice.

In order to identify the response as of type calendar i set the following

ResponseBuilder builder = Response.ok();
    builder.header("content-disposition",
            "attachment;filename=calendar.ics");

When IE8 receives the response it automatically attempts to download/open the file using my default Outlook instance.

This works across all browsers. It does have the overhead of requiring the request to the server however it also lets me apply extra processing on the request like validating the conference room is valid etc.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top