Download ICS file with Google Chrome on iPhone

a 夏天 提交于 2021-01-27 03:54:21

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!