Created
September 28, 2016 10:33
-
-
Save s-melnikov/c4c51e6db504289dbb38dece44e7b694 to your computer and use it in GitHub Desktop.
save file
This file contains hidden or 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 save(data, name) { | |
| var a = document.createElement('a') | |
| a.download = name + '.json' | |
| a.href = 'data:application/json,' + encodeURIComponent(JSON.stringify(data)) | |
| a.dataset.downloadurl = ['application/json', a.download, a.href].join(':') | |
| document.body.appendChild(a) | |
| a.click() | |
| document.body.removeChild(a) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment