How to click the button to save the picture on the mobile terminal

on WeChat, long press the picture to save the picture

if the implementation makes a button itself. Click to save this picture directly?

Mar.05,2021

looked for this answer before, but never found a suitable solution


refer to the following two types:
1. Window.open, will be blocked by the browser. (not recommended)

2. Html5 has a new attribute: download download directly. Just judge whether alink.download exists before.

function save() {
    var img = document.getElementById("testImg");
    var alink = document.createElement("a");
    a.href = img.src;
    a.download = "testImg.jpg";
    a.click();
}

ps: use its api if it's just a Wechat browser.


is there a solution?


you can use window.open () to

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bed2d7-31b7a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bed2d7-31b7a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?