[英]iOS download image from href a tag html
I have something very simple. 我有很简单的东西。
I will put a simple bloburl to a href of an a tag. 我将一个简单的bloburl放在一个标签的href中。
<a id="downloadReady" class="btn btn-primary" download=""
href="blob:https://pic2.conveyor.cloud/934d8e82-cfb2-43d4-b0f9-00822621f772">
Download Ready!
</a>
Super simple. 超级简单。
On android, windows, blackberry etc it works. 在android,windows,blackberry等平台上都可以使用。 On ios i get following message after 3 taps.
在ios上,点击3次后,我得到以下消息。
This website is repeatedly trying to open another application
Granted the image is large, not very but it was from iphone camera, on smaller images it works. 虽然图像很大,但不是很大,但它来自iphone相机,在较小的图像上可以使用。
I cannot embed in jsbin because there is a bug currently. 我无法嵌入jsbin,因为当前存在错误。 Maybe somebody can help me out?
也许有人可以帮助我?
Note: the code is used in a simple website, in the browser, not a native hybrid web app like ionic etc. 注意:该代码是在简单的网站,浏览器中使用的,而不是诸如ionic等的本机混合Web应用程序。
I was also facing exactly the same issue while downloading pdf on iOS using Chrome Browser. 使用Chrome浏览器在iOS上下载pdf时,我也遇到了完全相同的问题。 I used fileReader approach to fix that.
我使用fileReader方法来解决此问题。 Also I added this under condition that this code should work only for Chrome on iOS.
我还添加了此条件,条件是该代码仅适用于iOS上的Chrome。 Below is my code
下面是我的代码
if (window.navigator.userAgent.toLowerCase().indexOf('crios') > -1) {
const fileReader = new FileReader()
const blobUrl = new Blob([serviceResponse.data], { type:
'application/pdf' })
fileReader.onload = function (event) {
window.location.href = reader.result
}
fileReader.readAsDataURL(blobUrl)
}
Let me know in case you need further clarification. 如果您需要进一步澄清,请告诉我。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.