I want to Write Data to existing file using JavaScript.
I don\'t want to print it on console.
I want to Actually Write data to abc.txt
.
I read many answered que
I found good answers here, but also found a simpler way.
The button to create the blob and the download link can be combined in one link, as the link element can have an onclick attribute. (The reverse seems not possible, adding a href to a button does not work.)
You can style the link as a button using bootstrap
, which is still pure javascript, except for styling.
Combining the button and the download link also reduces code, as fewer of those ugly getElementById
calls are needed.
This example needs only one button click to create the text-blob and download it:
Write To File