

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
HTML DOM Anchor download Property
<p>The HTML DOM download property is used to set or return the value of the download attribute of a link.</p><p>Following is the syntax to set the download property −</p><pre class="result notranslate">anchorObject.download = file</pre><p>Above, file represents the file name you can set for the file to be downloaded. The actual extension will get suffixed.</p><p>Following is the syntax to return the download property: anchorObject.download</p><p>Let us now see an example to implement the DOM Anchor download property −</p><h2>Example</h2><p><a class="demo" href="http://tpcg.io/Y6Ww7n" rel="nofollow" target="_blank"> Live Demo</a></p><pre class="prettyprint notranslate"><!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></pre><h2>Output</h2><p><img src="https://www.tutorialspoint.com/assets/questions/media/24553/react.jpg" class="fr-fic fr-dib" style="width:600px; height:317px; border:1px solid black;" width="600" height="317"></p><p>Now, click on the button to display the value −</p><p><img src="https://www.tutorialspoint.com/assets/questions/media/24553/react_js.jpg" class="fr-fic fr-dib" style="width:600px; height:329px; border:1px solid black;" width="600" height="329"></p>
- Related Questions & Answers
- 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
- 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 hostname Property
Advertisements