我的网页有下载 Passbook .pkpass 文件的链接。 这在 iOS 的 Safari 中运行良好,因为 Apple 的浏览器支持 mime 类型:application.com/vnd.apple.pkpass
Facebook 的 iOS 浏览器(以及其他浏览器)(还)不支持这种 mime 类型。因此,如果用户从 Facebook 中点击指向我网站的链接,他们将无法下载我的 Passbook 文件。但是,如果他们单击“在 Safari 中打开”,则可以下载该文件。
如何编写我的网页,以便在点击链接时强制打开 iOS 上的 Safari?
安德鲁
最佳答案
这些 header 应该对您正在做的事情有帮助。
Content-Type "application/force-download"
Content-Description "File Transfer"
Content-Disposition attachment
ForceType "application/octet-stream"
我建议您尝试使用以下代码在您的 .htaccess 或 httpd.conf 文件中设置它们:
<FilesMatch "\.(pkpass)$">
Header set Content-Type "application/force-download"
Header set Content-Description "File Transfer"
Header set Content-Disposition attachment
Header set ForceType "application/octet-stream"
</FilesMatch>
这有点矫枉过正,但会确保在所有浏览器上强制下载。将 pkpass 更改为任何其他内容以强制下载任何其他文件类型。
关于facebook - 如何强制链接在 iOS Safari 中打开?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14537235/