Anchor download Property
Example
Get the value of the download attribute:
let text = document.getElementById("myAnchor").download;
Try it Yourself »
Change the value of the download attribute:
document.getElementById("myAnchor").download = "newValue";
Try it Yourself »
Description
The download property sets or returns the value of the download attribute of a link.
The download attribute defines the download target.
Syntax
Return the download property:
anchorObject.download
Set the download property:
anchorObject.download = filename
Parameters
Parameter | Description |
filename |
The text to be used as filename. The browser automatically detects the file extension (img, pdf, html, etc). If omitted, the original filename is used. |
Return Value
Type | Description |
String | The name of the download file. |
Browser Support
download
was introduced in HTML 5 (2014).
It is supported in all modern browsers:
Chrome | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes |
download
is not supported in Internet Explorer 11 (or earlier).
❮ Anchor Object