Javascript examples for DOM HTML Element:Anchor
The download property sets or gets the value of the download attribute of an anchor link.
Value | Description |
---|---|
filename | Set text to be used as the filename. If omitted, the original filename is used. |
A String, representing the name of the downloaded file
The following code shows how to Display the value of the download attribute of a link:
<!DOCTYPE html> <html> <body> <a id="myAnchor" href="http://java2s.com/resources/a.png" download="myDownloadFileName"> <img border="0" src="http://java2s.com/resources/a.png" alt="alt message" width="104" height="142"></a> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//from w w w .j a v a 2 s . com var x = document.getElementById("myAnchor").download; document.getElementById("demo").innerHTML = x; } </script> </body> </html>