Javascript-generated .ics file opens in Chrome and Firefox, but not in IE

Fer

I'm generating a .ics calendar entry from JS, next I open it using a data-URI:

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

Where "icsMSG" is the dynamically generated .ics file. Here's a sample output from console.log:

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//www.jungledragon.com//NONSGML v1.0//EN
BEGIN:VEVENT
UID:[email protected]
DTSTAMP:20140321T153010Z
ATTENDEE;CN=My Self ;RSVP=FALSE
CATEGORIES:APPOINTMENT
DTSTART:20140321T153010Z
DTEND:
LOCATION:5384 DA Heesch, The Netherlands
SUMMARY:JungleDragon Daylight Event
DESCRIPTION:Hey you!   \n \n  At this time in your calendar light conditions are great for the location you selected:\n \nhttp://www.ignore.org/apps/jd3/daylight#date=1392996610000&lat=51.73171&long=5.527827000000002\n\nHappy shooting, and be sure to share your wildlife photos back to http://www.jungledragon.com\nCheers,\nThe JungleDragon Team
END:VEVENT
END:VCALENDAR

The raw output will be have \n chars at the end of each line, as per the specification.

The above sample works fine when I run it from Chrome or Firefox, in both case it will open up my default Calendar application (Outlook 2013). In IE(11) and Opera, instead something weird happens. A new tab opens that has the above string as the URL, with all special chars URL-escaped. Like so:

data:text/calendar;charset=utf8,BEGIN%3AVCALENDAR%0AVERSION%3A2.0%0APRODID%3A-//www.jungledragon.com//NONSGML%20v1.0//EN%0ABEGIN%3AVEVENT%0AUID%[email protected]%0ADTSTAMP%3A20140321T153043Z%0AATTENDEE%3BCN%3DMy%20Self%20%3BRSVP%3DFALSE%0ACATEGORIES%3AAPPOINTMENT%0ADTSTART%3A20140321T153043Z%0ADTEND%3A%0ALOCATION%3A5384%20DA%20Heesch%2C%20The%20Netherlands%0ASUMMARY%3AJungleDragon%20Daylight%20Event%0ADESCRIPTION%3AHey%20you%21%20%20%20%5Cn%20%5Cn%20%20At%20this%20time%20in%20your%20calendar%20light%20conditions%20are%20great%20for%20the%20location%20you%20selected%3A%5Cn%20%5Cnhttp%3A//www.ignore.org/apps/jd3/daylight%23date%3D1392996643000%26lat%3D51.73171%26long%3D5.527827000000002%5Cn%5CnHappy%20shooting%2C%20and%20be%20sure%20to%20share%20your%20wildlife%20photos%20back%20to%20http%3A//www.jungledragon.com%5CnCheers%2C%5CnThe%20JungleDragon%20Team%0AEND%3AVEVENT%0AEND%3AVCALENDAR

Next, the new tab is blank and nothing happens. I'm not sure whether there is a syntax mistake in my .ics, but given that it works for Chrome and Firefox, I don't believe so.

Any thoughts?

Edit, extra info: If I manually open a downloaded .ics file with the exact same content, it does work also in IE and Opera. Something must be wrong with the way I open it using window.open?

Fer

Answering my own question:

The problem was not in the .ics output itself, rather it was in IE and Opera not treating the js-generated output as a file to download. To enforce such a download, is only possible from a server-side script.

I ended up recoding my logic to output the .ics file on the server-side, and by enforcing these headers:

header('Content-type: text/calendar; charset=utf-8');
header('Content-Disposition: attachment; filename=cal.ics');

It was a painful restructuring, but now it works across browsers.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Javascript-generated .ics file opens in Chrome and Firefox, but not in IE

From Dev

Getting Certificate error on IE and Chrome but opens in FireFox

From Dev

create a cmd shortcut which opens url in chrome, firefox and IE simultaneously

From Dev

Jquery Javascript only works on chrome and firefox, but not on IE

From Dev

JavaScript not working in IE and Firefox, works fine in Chrome

From Dev

JavaScript login button works in IE but not in Chrome or Firefox

From Dev

When I click on link it opens the two new tabs using jquery.This works in firefox but not working in chrome and IE

From Dev

PHP generated ICS file not working properly

From Dev

Javascript generated calendar showing different in mozilla firefox and chrome

From Dev

Methods from Javascript file will load in IE but not Chrome

From Dev

Leaflet.js file runs in Safari but not Firefox, Chrome or IE

From Dev

Leaflet.js file runs in Safari but not Firefox, Chrome or IE

From Dev

Vue.js Checkbox issue in Firefox, works file in Chrome and IE

From Dev

JavaScript submit does not work in Chrome/Safari, but works fine in Firefox/IE

From Dev

Javascript Countdown shows NaN in IE and Firefox, works in Chrome

From Dev

This Javascript doesn't work in IE but works in Chrome, Firefox and Opera

From Dev

JavaScript submit does not work in Chrome/Safari, but works fine in Firefox/IE

From Dev

JavaScript Behavior difference: IE11/Edge vrs Chrome/Firefox

From Dev

My javaScript code is causing IE to time out but works on Chrome and Firefox

From Dev

Javascript .open opens maximized in Chrome

From Dev

Generated DXF file opens in AutoCAD but crashes BricsCAD

From Dev

Javascript code undefined in IE11 Mobile browser but working in Chrome, Firefox, IE

From Dev

Chrome --app equivalent in Firefox\IE

From Dev

Working fine in IE but not in Firefox and Chrome

From Dev

Font works in IE, but but not Firefox or Chrome

From Dev

modal working on firefox and IE but not chrome

From Dev

JavaScript not working in IE but in Firefox

From Dev

Batch file opens Default Browser instead of Firefox

From Dev

Firefox opens a new tab instead of javascript code

Related Related

  1. 1

    Javascript-generated .ics file opens in Chrome and Firefox, but not in IE

  2. 2

    Getting Certificate error on IE and Chrome but opens in FireFox

  3. 3

    create a cmd shortcut which opens url in chrome, firefox and IE simultaneously

  4. 4

    Jquery Javascript only works on chrome and firefox, but not on IE

  5. 5

    JavaScript not working in IE and Firefox, works fine in Chrome

  6. 6

    JavaScript login button works in IE but not in Chrome or Firefox

  7. 7

    When I click on link it opens the two new tabs using jquery.This works in firefox but not working in chrome and IE

  8. 8

    PHP generated ICS file not working properly

  9. 9

    Javascript generated calendar showing different in mozilla firefox and chrome

  10. 10

    Methods from Javascript file will load in IE but not Chrome

  11. 11

    Leaflet.js file runs in Safari but not Firefox, Chrome or IE

  12. 12

    Leaflet.js file runs in Safari but not Firefox, Chrome or IE

  13. 13

    Vue.js Checkbox issue in Firefox, works file in Chrome and IE

  14. 14

    JavaScript submit does not work in Chrome/Safari, but works fine in Firefox/IE

  15. 15

    Javascript Countdown shows NaN in IE and Firefox, works in Chrome

  16. 16

    This Javascript doesn't work in IE but works in Chrome, Firefox and Opera

  17. 17

    JavaScript submit does not work in Chrome/Safari, but works fine in Firefox/IE

  18. 18

    JavaScript Behavior difference: IE11/Edge vrs Chrome/Firefox

  19. 19

    My javaScript code is causing IE to time out but works on Chrome and Firefox

  20. 20

    Javascript .open opens maximized in Chrome

  21. 21

    Generated DXF file opens in AutoCAD but crashes BricsCAD

  22. 22

    Javascript code undefined in IE11 Mobile browser but working in Chrome, Firefox, IE

  23. 23

    Chrome --app equivalent in Firefox\IE

  24. 24

    Working fine in IE but not in Firefox and Chrome

  25. 25

    Font works in IE, but but not Firefox or Chrome

  26. 26

    modal working on firefox and IE but not chrome

  27. 27

    JavaScript not working in IE but in Firefox

  28. 28

    Batch file opens Default Browser instead of Firefox

  29. 29

    Firefox opens a new tab instead of javascript code

HotTag

Archive