Anchor download Property

❮ Anchor Object

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.


Note

The download attribute was new in HTML 5 (2014).

See Also:

The HTML <a> download Attribute

The Anchor Object



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
StringThe 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
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.