title: Sweet Alert Pop up Prompt Before Downloading Canvas HTML Image to PNG
body: <p>in my Canvas drawing app I have a download to png button, I want to make it so the image off the canvas only downloads when the user clicks "yes save it" on my sweet alert pop up prompt. Right now it's still downloading automatically. Thank you for your help. (also if someone had a better way to download via Javascript that would help too, it's downloading the png but it is corrupt and I can't open it) </p>
  
  <pre><code>$('#download').click(function(){
      swal({
          title: "Are you finished your creation?",  
          text: "click yes to save",   
          type: "warning",  
          showCancelButton: true,   
          confirmButtonColor: "#f8c1D9",   
          confirmButtonText: "Yes, save it!",  
          closeOnConfirm: true 
      }, function (isConfirm) {      
          if (isConfirm) {
              swal("Saving!");
  
              var base64 = document.getElementById("canvas")
                .toDataURL("image/png")
                .replace(/^data:image\/[^;]/, 'data:application/octet-stream');
  
              document.getElementById("download-png").href = base64
          } else {
  
          }
  
          return false; 
      });
  });
  </code></pre>
  
  <p>html</p>
  
  <pre><code>&lt;div id="download"&gt;
      &lt;a href="#" id="download-png" download="image.png"&gt;&lt;img src="./assets/imgs/tools/save.png" /&gt;&lt;/a&gt;
  &lt;/div&gt;
  </code></pre>