Sometimes you want to save content, a text for example directly from the browser, without talking to a server.
Here I use the nice library FileSaver
<textarea id="notes" style="width:300px; height: 100px;">
Content
</textarea>
<br />
<button onclick="saveContent()">
Save
</button>
<script>
function saveContent () {
let data = notes.value
var blob = new Blob([data], {type: "text/plain;charset=utf-8"});
var name = prompt("Save file under")
if (name != "" ) {
saveAs(blob, name)
}
}
</script>
You can test it here SaveContent
Top comments (0)