Created
December 9, 2013 06:30
-
-
Save joshbeckman/7868209 to your computer and use it in GitHub Desktop.
Create a download link for JSON 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 makeJSONDownload(evt) { | |
window.URL = window.URL || window.webkitURL; | |
var content = JSON.stringify(p); | |
var blob = new Blob([content], {type: 'application/json'}); | |
var link = document.createElement('a'); | |
link.href = window.URL.createObjectURL(blob); | |
link.textContent = 'download here'; | |
link.download = 'test.json'; | |
document.getElementById('div').appendChild(link); | |
} | |
document.getElementById('btn').addEventListener('click', makeJSONDownload, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment