1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| function download(url, fileName) { var xhh = new XMLHttpRequest(); xhh.open("post", url, true); xhh.responseType = 'blob'; xhh.onreadystatechange = function () { if (xhh.readyState === 4 && xhh.status === 200) { var blob = xhh.response; const url = window.URL.createObjectURL(blob); var link = document.createElement('a'); link.href = url; link.download = fileName; link.click(); } }; xhh.send(); }
download('https://image.dqv5.com/public/bear.png','bear.png');
|