Created
November 5, 2013 08:34
-
-
Save luokebi/7315666 to your computer and use it in GitHub Desktop.
download a image using javascript from the image url
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 a = document.createElement('a'); | |
var e = document.createEvent("MouseEvents"); | |
e.initMouseEvent("click", !0, !0, window, 1, 0, 0, 0, 0, !1, !1, !1, !1, 0, null); | |
a.setAttribute("href", 'http://www.baidu.com/img/bdlogo.gif'); //the image url | |
a.setAttribute("download", "kkk.png"); // the file name | |
a.dispatchEvent(e); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment