下载属性在 safari 中不起作用 [英] Download attribute not working in safari

查看:42
本文介绍了下载属性在 safari 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在链接中使用了下载属性:

I am using a download attribute in my link:

   <a style="color:white" download="myimage" href="images/myimage.jpg">Download image</a>

它在几乎所有浏览器中都运行良好.这意味着,如果我点击链接,图像会自动下载.我在 Mac 上的 safari 10.1.2 中对其进行了测试,并且运行良好.

It is working very well in almost all browsers. This means, if I click on the link the image is automatically downloaded. I tested it in safari 10.1.2 on my mac and it is working fine.

但是在我使用 safari 10.0.3 的朋友 mac 上,它不起作用.他是说该图像仅在新窗口中打开但无法下载.

But on my friends mac who is working with safari 10.0.3 it is not working. He is saying that the image is only opening in a new window but not downloading.

为什么会发生这种情况,我该怎么做才能让它在任何地方都能正常工作?

Why is this happening and what can I do to make it work anywhere?

推荐答案

根据 https://developer.apple.com/library/content/releasenotes/General/WhatsNewInSafari/Articles/Safari_10_1.html,它是在 Safari 10.1 中添加的:

According to https://developer.apple.com/library/content/releasenotes/General/WhatsNewInSafari/Articles/Safari_10_1.html, it was added in Safari 10.1:

HTML5 下载属性锚元素的下载属性表示链接目标是一个下载链接文件,而不是导航链接.当您单击带有下载属性,目标作为文件下载.可选,下载属性的值提供了建议的名称文件.

HTML5 Download Attribute The download attribute for anchor elements indicates that the link target is a download link that downloads a file, instead of a navigational link. When you click a a link with the download attribute, the target is downloaded as a file. Optionally, the value of the download attribute provides the suggested name of the file.

从我自己的测试来看,它似乎在 iOS Safari 11.1 中不可用,这让我有点困惑.基于它们相似的版本编号,我希望它们在标准支持方面是相同的.

It doesn't seem to be available in iOS Safari 11.1 though from my own testing, which has me a bit confused. I'd expect them to be equal in standards support, based on their similar version numbering.

这篇关于下载属性在 safari 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆