0
downloadBtn.addEventListener('click', function(e) {
   let a = document.createElement("a");
   a.href = imgTag.src;
   a.target = "_blank";  // open the link in a new tab
   a.click();
});

the code above opens the image file in a new browser tab, even after playing with it and trying to make it download the image file, it still and always opens it in rather the same browser tab or in a new browser tab.

If this helps I am testing this on a domain name that is non HTTPS,

I want the button to not open promts but directly download the image file, I read somewhere there is browser blocking for security reasons and that i should use BLOB to find a work around about this.

Can any one help me with this

trying to download the image directly, but it opens the file in browser

0 Answers0