DEV Community

artydev
artydev

Posted on

2 1

Save content directly from browser

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

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay