Last active
October 14, 2022 15:31
-
-
Save nhattruongniit/6d0b76751b5a3a24c7f11d3235a76df6 to your computer and use it in GitHub Desktop.
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 download_data(filename, data) { | |
| var blob = new Blob([data], {type: 'application/json'}); | |
| if(window.navigator.msSaveOrOpenBlob) { | |
| window.navigator.msSaveBlob(blob, filename); | |
| } | |
| else{ | |
| var elem = window.document.createElement('a'); | |
| elem.href = window.URL.createObjectURL(blob); | |
| elem.download = filename; | |
| document.body.appendChild(elem); | |
| elem.click(); | |
| document.body.removeChild(elem); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment