You can use this code:
// Assuming the text you want to save is in variable 'contentVar' uriContent = "data:application/octet-stream," + encodeURIComponent(contentVar); window.location.href = uriContent;
Your browser should then download a file that contains whatever is inside
The downside of this is that you can't set the file name. Doing this in a cross-browser way is difficult, but as always, there's a library to help! FileSaver.js
©2020 All rights reserved.