MoreLesson 246Free preview
Download Link
This lesson is part of How To · All levels
Summary
The download attribute on the link asks the browser to download the file, not open it in a new tab. You can suggest the name of the downloaded file, but the browser still decides the behavior eventually. For files created on the client side, use Blob and URL.createObjectURL so that users can download data without a server.
Key points
- <a href="laporan.pdf" download> requested download; download="nama.pdf" suggested the file name.
- The download attribute is only reliable for files of the same origin.
- Without the download attribute, the browser may open supported files such as PDFs or images.
- Blob and URL.createObjectURL allow the download of JavaScript-generated files.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.