我有一些代码可以将图像直接保存到设备中。这在桌面上完美工作。
function saveQR() {
var link = document.createElement('a'),
cpdTxt = '已保存到系统相册',
qrSve = function() {
$('.msg').animate({
top: '48%'
});
$('.modal').fadeOut(300);
};
link.href = './assets/downloads/qr.png';
link.download = 'myQR.png';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
$('.msg').text(cpdTxt.replace());
$('.msg').animate({
top: '50%'
});
$('.ref-lnkcpy').fadeIn(400);
setTimeout(qrSve, 2000);
}
However, when I tried it using an iPhone, it just opens the image to another tab. Is there a way to resolve this?