DEV Community

artydev
artydev

Posted on

1 1

Download attribute

Here is another way to download stuff created dynamically using "download" attribute

<a download="hello.txt" href='#' id="link">Download</a>

<script>
  let blob = new Blob(["Hello, world!"], {type: 'text/plain'});
  link.setAttribute("download", link.getAttribute("download"))
  link.href = URL.createObjectURL(blob);
</script>

You can test it here : ForceDownload

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more