Last active
December 31, 2015 14:39
-
-
Save toruta39/8001774 to your computer and use it in GitHub Desktop.
Create and download a blob in JS. Tested on the latest Chrome stable
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
var output = {someKey: "someValue"}; | |
var blob = new Blob([JSON.stringify(output)], {type: 'application/json'}); | |
var anchor = document.createElement('a'); | |
anchor.setAttribute('href', window.URL.createObjectURL(blob)); | |
anchor.setAttribute('download', 'data' + Date.now() + '.json'); | |
anchor.click(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment