Last active
September 30, 2024 11:13
-
-
Save jrc03c/17a87c50af42fb55f7270d4047cf7497 to your computer and use it in GitHub Desktop.
Download text as a 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 downloadText(filename, text){ | |
const a = document.createElement("a") | |
a.href = "data:text/plain;charset=utf-8," + encodeURIComponent(text) | |
a.download = filename | |
a.dispatchEvent(new MouseEvent("click")) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment