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

File download using anchor download attribute doesn't work on iOS Chrome and iOS Firefox #1

Open
sylvie-uxe opened this issue Jan 24, 2021 · 0 comments

Comments

@sylvie-uxe
Copy link
Owner

I have an anchor with a download attribute for saving a calendar file .ics of the GitHub planned contributions.
When the user clicks on the anchor, a *.ics file is generated from the graph:

const icsFile = new File(data, "my-github-graph.ics", {
        type: "text/calendar"
});

Then, an URL is created for this file:

if (icsFileURL) {
        window.URL.revokeObjectURL(icsFileURL);
}
icsFileURL = window.URL.createObjectURL(icsFile);

Finally, the href of the anchor is programmatically set to this URL:

const saveAsCalButton = document.getElementById("save-as-calendar");
saveAsCalButton.onclick = (event) => {
        event.target.href = generateCalendarFile();
};

It works fine on all desktop web browsers and on iOS Safari but not on iOS Chrome and iOS Firefox where a click on the anchor doesn't do anything. The href is correctly set to, for instance: blob:https://my-github-graph.web.app/b0037bb7-f20f-4e26-b9c0-5f4b32f486c1.

Stackoverflow issue

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

1 participant