Javascript 将图像下载到ipad safari和chrome上的文件
我的单页web应用程序有用于下载需要从错误中正确恢复的文件的按钮。 为此,我有以下代码:Javascript 将图像下载到ipad safari和chrome上的文件,javascript,html,ipad,safari,mobile-safari,Javascript,Html,Ipad,Safari,Mobile Safari,我的单页web应用程序有用于下载需要从错误中正确恢复的文件的按钮。 为此,我有以下代码: // to download a file we don't want to use window.location.assign because in case of error the broswer // will redirect to the error page, instead we create an invisible iframe and set src to it
// to download a file we don't want to use window.location.assign because in case of error the broswer
// will redirect to the error page, instead we create an invisible iframe and set src to it
function downloadToFile(url) {
let iframe = document.getElementById('downloadFileIframe');
if (!iframe) {
iframe = document.createElement('iframe');
iframe.setAttribute('id', 'downloadFileIframe');
iframe.style.display = 'none';
document.body.appendChild(iframe);
}
iframe.setAttribute('src', url);
}
这在台式机上非常有效
然而,在iPadSafari上,我得到了下载图像的提示,但它们是作为“数据”而不是图像到达的
在iPAD chrome上,上面的代码根本不起任何作用
有什么帮助吗