是否可以使用自定义标题和内容打开新的浏览器窗口? [英] Is it possible to open new browser window with custom headers and content?
问题描述
我有一个Sencha Touch网络应用程序。我正在尝试生成一个日历事件文件并在另一个窗口中打开它,因此迫使iOS要求用户将此事件导入标准日历。
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.
我可以 window.open
然后使用 document.write
生成我想要的文件,但我还需要指定具有内容类型的自定义标头,以便Safari将其识别为日历文件。
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.
有可能吗?
推荐答案
如果您重定向到 window.open
a 数据URI ,您可以指定MIME类型。
If you redirect to or window.open
a data URI, you can specify a MIME type.
作为一个简单的测试(iOS 6上的Safari),我手动导航到这个数据URI ......
As a simple test (Safari on iOS 6), I navigated manually to this data URI...
data:text/calendar;base64,QkVHSU46VkNBTEVOREFSDQpWRVJTSU9OOjIuMA0KUFJPRElEOi0vL2hhY2tzdy9oYW5kY2FsLy9OT05TR01MIHYxLjAvL0VODQpCRUdJTjpWRVZFTlQNClVJRDp1aWQxQGV4YW1wbGUuY29tDQpEVFNUQU1QOjE5OTcwNzE0VDE3MDAwMFoNCk9SR0FOSVpFUjtDTj1Kb2huIERvZTpNQUlMVE86am9obi5kb2VAZXhhbXBsZS5jb20NCkRUU1RBUlQ6MTk5NzA3MTRUMTcwMDAwWg0KRFRFTkQ6MTk5NzA3MTVUMDM1OTU5Wg0KU1VNTUFSWTpCYXN0aWxsZSBEYXkgUGFydHkNCkVORDpWRVZFTlQNCkVORDpWQ0FMRU5EQVI=
...和这个弹出up:
...and this pops up:
这篇关于是否可以使用自定义标题和内容打开新的浏览器窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!