html - 下载属性在 safari 中不起作用

标签 html macos download safari attributes

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

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

它在几乎所有浏览器中都运行良好。这意味着,如果我点击链接,图像会自动下载。我在我的 mac 上的 safari 10.1.2 中测试了它,它工作正常。

但是在我使用 safari 10.0.3 的 friend mac 上,它不起作用。他是说图片只能在新窗口中打开但不能下载。

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

最佳答案

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

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 中不可用,这让我有点困惑。基于它们相似的版本编号,我希望它们在标准支持方面是平等的。

关于html - 下载属性在 safari 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46690722/

相关文章:

javascript - 使用jquery获取多个文件输入中每个文件的内容

html - 是否可以将整个 'card' 包装在 <a> 标签中?

Node.js 下载多个文件

php - 将所有 Mysql 值相加 PHP

iphone - 核心音频 : Why does ExtAudioFileCreateWithURL return 0xFFFFFFCE?

javascript - 下载前强制询问文件保存位置

javascript - 我想在单击按钮时使用 JavaScript 插入文本。但 `` `.value( )`` ` 似乎不起作用

javascript - 如何找到数组中第二好的?

java - mac中JAVA_HOME设置错误

objective-c - 有没有办法使用内存映射文件访问从文件创建 CFData 对象?