Skip to content

Instantly share code, notes, and snippets.

@jmcarp
Created March 1, 2014 15:35
Show Gist options
  • Star 13 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save jmcarp/9291539 to your computer and use it in GitHub Desktop.
Save jmcarp/9291539 to your computer and use it in GitHub Desktop.
Forcing a file download in JavaScript
function forceDownload(href) {
var anchor = document.createElement('a');
anchor.href = href;
anchor.download = href;
document.body.appendChild(anchor);
anchor.click();
}
@akas089
Copy link

akas089 commented Aug 4, 2022

Not work download but view image in page

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment