Is it possible to open new browser window with custom headers and content?

杀马特。学长 韩版系。学妹 提交于 2019-12-13 19:35:35

问题


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

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