I am trying to download an image element on a webpage that is dynamically set using the use-react-screenshot library. Because of this I cannot download the image using a file name or link, so I have been attempting to download it based on the image element id.
Currently what I have is
var ss = document.createElement('a');
ss.setAttribute('href', "#screenshot");
ss.setAttribute('download', fileName);
ss.style.display = 'none';
document.body.appendChild(ss);
ss.click();
document.body.removeChild(ss);
where screenshot is the id of the image element containing the image I want to download
Is it even possible to do this or should I use some other method?