【发布时间】:2014-05-05 23:47:11
【问题描述】:
我正在使用goqr.me api 创建二维码图像。现在我想为二维码图片创建一个下载链接。
我正在以这种方式创建 qrcode 图像:
function generateQrcode(data) {
var params = {
data: data,
size: '200x200',
margin: 0
};
// populate the preview box with the generate qrcode
var dwnldUrl = 'https://api.qrserver.com/v1/create-qr-code/?'+$.param(params);
previewBox.html('<img src="'+dwnldUrl+'" alt="qrcode-image"/>');
}
我想要一个二维码图片的下载按钮,如下所示:
$('#qrcode-dwnld-btn').click(function() {
// something to trigger download for the image ....
}
或者有没有其他的跨浏览解决方案?
感谢您的帮助。
【问题讨论】:
-
只需创建一个 标签,其 href = dwnlUrl?!
-
@Alex,是的,试过了。但它确实在同一个窗口中打开,而不是下载。
标签: jquery cross-browser download qr-code