Created
December 15, 2019 18:20
-
-
Save denvit/afbee83c640d5f609e0ca7436073907a to your computer and use it in GitHub Desktop.
Save content to file using javascript
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
<script src="http://cdn.jsdelivr.net/g/filesaver.js"></script> | |
<script> | |
function SaveAsFile(t,f,m) { | |
try { | |
var b = new Blob([t],{type:m}); | |
saveAs(b, f); | |
} catch (e) { | |
window.open("data:"+m+"," + encodeURIComponent(t), '_blank',''); | |
} | |
} | |
SaveAsFile("text","filename.txt","text/plain;charset=utf-8"); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment