Skip to content Skip to sidebar Skip to footer

No Saving Or Outputting Is Possible In Javascript?

In this question I just learned how to illicit one desired element out of a Google translate page. There I have also learned that placing anything into clipboard in Javascript is l

Solution 1:

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 contentVar.

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

Post a Comment for "No Saving Or Outputting Is Possible In Javascript?"