Last active
July 23, 2017 13:40
-
-
Save NrI3/afef82d3bcb2a722b57dc29546bc06ca to your computer and use it in GitHub Desktop.
[JS] Downloader text as 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
| window.stringToFile = function(content,name){ | |
| var o = document.createElement('a'); | |
| o.type = 'application/octet-stream'; | |
| o.target = '_blank'; | |
| o.download = name; | |
| o.href = URL.createObjectURL(new Blob([content],{type:'text/plain'})) | |
| console.log('Downloading ..'); | |
| o.click(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment