模拟保存图像为 [英] Simulate Save Image As
本文介绍了模拟保存图像为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在点击图片时触发另存为图片操作?
How can I trigger a "Save Image As" action when an image is clicked?
推荐答案
您可以使用HTML5的下载属性,并且没有jQuery:
You can do it using HTML5's download attribute and no jQuery with:
<a href="http://farm3.staticflickr.com/2881/10000610654_fdf29eb02f_q.jpg" download>
<img src="http://farm3.staticflickr.com/2881/10000610654_fdf29eb02f_q.jpg" alt="Smiley face">
</a>
您也可以声明文件名,如果您希望它的名称不是默认值:
You can also declare the filename if you would like it to take a name other than default:
<a href="http://farm3.staticflickr.com/2881/10000610654_fdf29eb02f_q.jpg" download="fileName.jpg">
<img src="http://farm3.staticflickr.com/2881/10000610654_fdf29eb02f_q.jpg" alt="Smiley face">
</a>
这篇关于模拟保存图像为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文