Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICS download link does not work on Microsoft browser (including edge) #71

Closed
dogawaf opened this issue Aug 29, 2019 · 6 comments
Closed

Comments

@dogawaf
Copy link
Contributor

dogawaf commented Aug 29, 2019

The ICS download link proposed by this library does not work on Microsoft browsers because they do not support navigating to data uri:

For security reasons, data URIs are restricted to downloaded resources. Data URIs cannot be used for navigation, for scripting, or to populate frame or iframe elements.
source: https://docs.microsoft.com/en-us/previous-versions//cc848897(v=vs.85)

@alies-dev
Copy link
Collaborator

@dogawaf
There is nothing to do within this lib. But you can bypass it: redirect user to a route to download a file instead

@dogawaf
Copy link
Contributor Author

dogawaf commented Aug 29, 2019

I would not ask you to fix IE limitations :)

But at least the limitation should be documented here.

More insights:

There is also this JS library that may help: http://danml.com/download.html

@alies-dev
Copy link
Collaborator

alies-dev commented Aug 29, 2019

done: added to the bottom of the Usage section: https://github.com/spatie/calendar-links#usage, thanks a lot @dogawaf !

@robbygeybels
Copy link

Does it work on the chromium based Edge browsers?

@wxactly
Copy link
Contributor

wxactly commented Sep 3, 2020

Use download.js version 1.4.8 to trigger ics file download in the browser - it works in Internet Explorer!

PHP:

$link = Link::create('My Event', $from, $to);
echo '<a href="' . $link->ics() . '" class="ics-link">Download My Event</a>';

jQuery:

$('.ics-link').click(function (event) {
  var href = $(this).attr('href');
  download(href, 'download.ics');
  event.preventDefault();
});

Full docs: https://github.com/rndme/download

@alies-dev
Copy link
Collaborator

alies-dev commented Sep 3, 2020

Hey @wxactly

Let me improve (a bit) your solution and rely on download attribute instead of .ics-link:

$link = Link::create('My Event', $from, $to);
echo '<a href="' . $link->ics() . '" class="ics-link" download="event.ics">Download My Event</a>';
$('a[download]').click(function (event) {
  var href = $(this).attr('href');
  var storeAsFilename = $(this).attr('download') || 'event.ics';
  download(href, storeAsFilename);
  event.preventDefault();
});

UPD: or with less jQuery:

$('a[download]').click(function (event) {
  /** @type {HTMLAnchorElement} */
  var anchor = event.target;
  var storeAsFilename = anchor.download || 'event.ics';
  download(anchor.href, storeAsFilename);
  event.preventDefault();
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants