使用jQuery / Javascript打开“保存图像”对话框? [英] Open the Save Image dialog using jQuery/Javascript?

查看:99
本文介绍了使用jQuery / Javascript打开“保存图像”对话框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户点击网页上的图片时,我想触发浏览器的保存图像对话框并让用户将图像保存在硬盘上。是否有使用jQuery / Javascript的跨浏览器方式?

When a user clicks on an image on a web page, I'd like to trigger the browser's Save Image dialog and to let the user save the image on their hard drive. Is there a cross-browser way to do this with jQuery/Javascript?

推荐答案

不完全是,但你可以通过超链接来做到这一点到img文件并在服务器响应中设置content-type和content-disposition标头。尝试,例如,application / x-download,以及指定的其他标题这里

Not precisely, but you can do it by hyperlinking to the img file and setting the content-type and content-disposition headers in the server response. Try, e.g., application/x-download, plus the other headers specified here.

这篇关于使用jQuery / Javascript打开“保存图像”对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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