1function download(source){
2 const fileName = source.split('/').pop();
3 var el = document.createElement("a");
4 el.setAttribute("href", source);
5 el.setAttribute("download", fileName);
6 document.body.appendChild(el);
7 el.click();
8 el.remove();
9}
1var a = $("<a>").attr("href", "http://i.stack.imgur.com/L8rHf.png").attr("download", "img.png").appendTo("body");
2
3a[0].click();
4
5a.remove();