Front-end image download

https://www.cnblogs.com/jyuf/p/7251591.html

https://segmentfault.com/a/1190000010694215

//A browser window will be reopened, and I will be doing research later. I can't download cross-domain images with canvas.todataURL $(function () { function download(src) { var $a = document.createElement('a'); $a.setAttribute("href", src); $a.setAttribute("download", ""); var evObj = document.createEvent('MouseEvents'); evObj.initMouseEvent( 'click', true, true, window , 0, 0, 0, 0, 0, false, false, true, false, 0, null); $a.dispatchEvent(evObj); console.log("Successful download") }; download(" https:// zfhyegold.oss-cn-shenzhen.aliyuncs.com/upload/3939eae7-0e21-4866-9413-ebc455e6f507.jpg ") })

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325055930&siteId=291194637
Recommended