I've built a simple web app which creates an image from a canvas
element using canvas.toDataURL()
. I then create an anchor tag using the data URI, containing a download
attribute. Something like this:
<a href="data:image/jpeg;base64,somedata" download="filename.jpg">Download</a>
This works great on Android/MacOS devices on Chrome and Safari - clicking the anchor downloads the data URI as a .jpg
file.
But on iOS Chrome clicking the link does nothing. To download the file it requires opening the anchor in a new tab (which displays the image), then saving the image.
I have tried adding a target="_blank"
but that does not achieve the desired result.
Is there a way to make iOS work like Android/MacOS, where clicking the link initiates the download?