I've seen this question a lot but nothing answered my question (or what i've found).
onClick
I point to a url of the thing I click on. <- that bit isn't really an issue.
My HTML looks like:
<a id="img_dwn_gen" href="" style="display: none; visibility: hidden; opacity: 0;"><a/>
Then within my onClick
event I attach the attribute to the image and then set a timeOut. As I need to wait a bit to grab the image.
$("#img_dwn_gen").attr("src","www.path/to/image.com");
setTimeout(function() {
$("#img_dwn_gen").trigger('click');
}, 500)
I tried using the download
attribute which works but it needs to work on IE9+ which doesn't support the download
attribute.
How can I add an image path to a HTML attribute and force the browser to automatically download it regardless of browsers (IE9+ and all latest).
It needs to be done in the front-end JS as well because I can't access the url path anywhere else.