Anchor download Property - Change the value of the download attribute of a link: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Anchor

Description

Anchor download Property - Change the value of the download attribute of a link:

Demo Code

ResultView the demo in separate window

<!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>

Related Tutorials