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)

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free