问题
I have an ICS file ('text/calendar' MIME type) stored on my server.
In JavaScript I call:
window.open("/path/to/file.ics");
It works on all browsers, even on Safari on my iPhone. But when I try on Chrome (the iPhone version) nothing happens. Nothing downloads. There are no errors on the screen―nothing.
Maybe someone has been there before and has some suggestions.
Thanks in advance!
回答1:
It should also be possible to use the good old create a download link, append it to the document, click it, and then remove it trick.
let icsLink = document.createElement("a");
icsLink.style.display = "none";
icsLink.href = "/path/to/file.ics";
icsLink.setAttribute("download","download");
document.body.appendChild(icsLink);
icsLink.click();
document.body.removeChild(icsLink);
来源:https://stackoverflow.com/questions/21341816/download-ics-file-with-google-chrome-on-iphone