Last active
December 28, 2017 06:17
-
-
Save LiYiBin/8e88620b384bc004b82d1827f63ef0cd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var uri = $0.toDataURL(); | |
function download(dataurl, filename) { | |
var a = document.createElement('a'); | |
a.href = dataurl; | |
a.setAttribute('download', filename); | |
var e = document.createEvent('MouseEvents'); | |
e.initEvent('click', false, true); | |
a.dispatchEvent(e); | |
return false; | |
} | |
download(uri, "test.jpg"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment