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

AWS Q Developer image

Your AI Code Assistant

Automate your code reviews. Catch bugs before your coworkers. Fix security issues in your code. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

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

Okay