I have this code for downloading images but when I click the download button it will start the download process but the download doesn't complete and no file is received but a type error is found.
<html>
<head>
<script type="text/javascript">
function prepHref(linkElement) {
var myDiv = document.getElementById('fullsized_image_holder');
var myImage = myDiv.children[0];
linkElement.href = myImage.src;
}
</script>
</head>
<body>
<div id="fullsized_image_holder">
</div>
<a href="#" onclick="prepHref(this)" download>Click here to download image</a>
</body>
</html>