我有以下JS代码,可让用户下载pdf文件。此代码有效,但在Ipad和Iphone上除外。
//s is the url to download
iso.downlURL = function(s)
{
var iframe = document.getElementById("hiddenDownloader");
if (iframe === null)
{
iframe = document.createElement('iframe');
iframe.id = "hiddenDownloader";
iframe.style.visibility = 'hidden';
document.body.appendChild(iframe);
}
iframe.src = s;
return true;
};
我发现了以下帖子,可能有同样的问题:
File Download using iframe not working in Iphone/Ipad
但是我不确定他的建议是什么,如何更改?
-------------更新---------------------
我可能应该提到ipad和iphone的问题是下载按钮不可点击。它只是灰色/禁用
答案 0 :(得分:0)
尝试在隐藏的iframe中显示PDF。在某些会被黑客下载的系统上。
它无法在iOS上使用,因为Mobile Safari没有任何“下载PDF”的概念。在Mobile Safari中下载PDF的唯一方法是:
如果您想为不懂下载的浏览器提供可靠的“下载PDF”功能并具有合理的过渡位置,请使用the Content-Disposition
header和常规链接。