Javascript 下载「;pdf";按钮在ipad/iphone上不起作用
我有下面的JS代码,可以让用户下载pdf文件。除了在Ipad和Iphone上,这段代码是有效的Javascript 下载「;pdf";按钮在ipad/iphone上不起作用,javascript,iframe,Javascript,Iframe,我有下面的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'); ifram
//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;
};
我发现以下帖子可能也有同样的问题:
但我不确定他建议的解决方案是什么,如何改变它
-------------更新---------------------
我可能应该提到ipad和iphone的问题是下载按钮不可点击。在隐藏的iframe中显示PDF的尝试是灰色/禁用的。在某些系统上,它将充当黑客,使其被下载 它在iOS上不起作用,因为Mobile Safari没有任何“下载PDF”的概念。在Mobile Safari中下载PDF的唯一方法是:
如果你想要一个可靠的“下载PDF”功能,对于那些不懂下载的浏览器来说,它有一个合理的空闲位置,那么就使用它和一个常规链接。它说为iPhone/iPadt设置
window.location=s
,这个问题与你发布的代码无关。请在你的问题中输入相关代码。然后忽略我发布的代码,我说这些代码可能是相关的。我已经发布了导致问题的代码