Javascript examples for DOM HTML Element:Anchor
Anchor download Property - Change 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()">change the value of the download attribute of the image link above</button> <p id="demo"></p> <script> function myFunction() {/* ww w . j av a 2 s . com*/ document.getElementById("myAnchor").download = "newValue"; document.getElementById("demo").innerHTML = "The value of the download attribute was changed from 'myDownloadFileName' to 'newValue'."; } </script> </body> </html>