Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 将图像下载到ipad safari和chrome上的文件_Javascript_Html_Ipad_Safari_Mobile Safari - Fatal编程技术网

Javascript 将图像下载到ipad safari和chrome上的文件

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

我的单页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
    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上,上面的代码根本不起任何作用

有什么帮助吗