Created
March 5, 2020 14:28
-
-
Save seunggabi/4ba2a426318f87459736a355467c113f to your computer and use it in GitHub Desktop.
download.js
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
function download(name, url) { | |
const save = document.createElement('a'); | |
save.download = name; | |
save.href = url.replace(/https?:\/\//gi, '://'); | |
save.target = '_blank'; | |
document.body.appendChild(save); | |
save.click(); | |
document.body.removeChild(save); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment