Javascript Question

How I can create a button for save a image with Javascript or any Javascript framework?

I would like save with a button a generated picture. I see the fastest solution is

, probably
or any framework.

My application generate a
label, for example:

<img src = "data:image/png;base64,iVBORw0KGgo...(it's very long)"/>

The many problem is the
attribute because change for my application, first I need catch the URL of this.

Thank you very much!


You can use the download attribute in HTML. If the img src is automatically generated, you could use the script below to put it in the href:

$('#save').prop('href', $('img').prop('src'));
<img src=""/><br/>
<a id='save' download>Save</a>

<script src=""></script>