Get the App
SLTechnology News&Howtos  ›  Development  › 

Example Analysis of canvas Picture download in JavaScript

Shulou Source: shulou.com Published: 2022-06-01 04:34:47 09月12日 Update

This article shares with you the content of a sample analysis of canvas image downloads in JavaScript. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Canvas picture download (compatible with all browsers)

/ / saved in png format document.getElementById ("save"). Onclick = function () {var canvas = document.getElementById ("canvas"); if (window.navigator.msSaveOrOpenBlob) {/ / ie browser var imgData = canvas.msToBlob (); var blobObj = new Blob ([imgData]); window.navigator.msSaveOrOpenBlob (blobObj, "expert certified QR code .png") } else {/ / Google Firefox downLoad (canvas.toDataURL ("image/png"));}} / download image function downLoad (url) {var oA = document.createElement ("a"); oA.download = 'expert certified QR code'; / / set the file name for download. Default is' download 'oA.href = url; oA.className = "qrcode" document.body.appendChild (oA) OA.click (); oA.remove (); / / delete the created elements after download} Thank you for reading! This is the end of this article on "sample Analysis of canvas Picture downloads in JavaScript". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!

Tags: Pictures picture downloads browsers examples analysis experts content more articles 2D QR codes authentication good practical elements file names articles format Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Microsoft OPPO Reno Huawei Docker