-
-
Save LarryKHite/fa1c083ee5df4738b79091ebbabaf3d0 to your computer and use it in GitHub Desktop.
Forcing a file download in JavaScript
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 forceDownload(href) { | |
var anchor = document.createElement('a'); | |
anchor.href = href; | |
anchor.download = href; | |
document.body.appendChild(anchor); | |
anchor.click(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment