
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
HTML DOM Anchor download Property
The HTML DOM download property is used to set or return the value of the download attribute of a link.
Following is the syntax to set the download property −
anchorObject.download = file
Above, file represents the file name you can set for the file to be downloaded. The actual extension will get suffixed.
Following is the syntax to return the download property: anchorObject.download
Let us now see an example to implement the DOM Anchor download property −
Example
<!DOCTYPE html> <html> <body> <h2>ReactJS</h2> <a id="myid" href="http://www.tutorialspoint.com/images/reactjs.png" download="Learn ReactJS"> <img src="http://www.tutorialspoint.com/images/reactjs.png" alt="ReactJS" width="200" height="200"></a> <button onclick="display()">Display the value</button> <p id="demo"></p> <script> function display() { var val = document.getElementById("myid").download; document.getElementById("demo").innerHTML = val; } </script> </body> </html>
Output
Now, click on the button to display the value −
- Related Articles
- HTML DOM Anchor hostname Property
- HTML DOM Anchor protocol Property
- HTML DOM Anchor password Property
- HTML DOM Anchor pathname Property
- HTML DOM Anchor href Property
- HTML DOM Anchor origin Property
- HTML DOM Anchor port Property
- HTML DOM Anchor hreflang Property
- HTML DOM Anchor hash Property
- HTML DOM Anchor rel Property
- HTML DOM Anchor search Property
- HTML DOM Anchor target Property
- HTML DOM Anchor text Property
- HTML DOM Anchor type Property
- HTML DOM Anchor username Property

Advertisements