问题
I have a Sencha Touch web application. I'm trying to generate a calendar event file and open it in another window hence forcing iOS to ask user to import this event into standard calendar.
I can do window.open
and then use document.write
to generate the file I want, but I also need to specify custom headers with content-type so Safari would recognize it as a calendar file.
Is it possible?
回答1:
If you redirect to or window.open
a data URI, you can specify a MIME type.
As a simple test (Safari on iOS 6), I navigated manually to this data URI...
data:text/calendar;base64,QkVHSU46VkNBTEVOREFSDQpWRVJTSU9OOjIuMA0KUFJPRElEOi0vL2hhY2tzdy9oYW5kY2FsLy9OT05TR01MIHYxLjAvL0VODQpCRUdJTjpWRVZFTlQNClVJRDp1aWQxQGV4YW1wbGUuY29tDQpEVFNUQU1QOjE5OTcwNzE0VDE3MDAwMFoNCk9SR0FOSVpFUjtDTj1Kb2huIERvZTpNQUlMVE86am9obi5kb2VAZXhhbXBsZS5jb20NCkRUU1RBUlQ6MTk5NzA3MTRUMTcwMDAwWg0KRFRFTkQ6MTk5NzA3MTVUMDM1OTU5Wg0KU1VNTUFSWTpCYXN0aWxsZSBEYXkgUGFydHkNCkVORDpWRVZFTlQNCkVORDpWQ0FMRU5EQVI=
...and this pops up:

来源:https://stackoverflow.com/questions/28662653/is-it-possible-to-open-new-browser-window-with-custom-headers-and-content