0

I've an image that I want to download on IE. After looking at Google and several stackoverflow questions I found that the best solution for the other common browsers is the HTML5 download attribute:

<a href="/barImage.jpg" target="_blank" download>Foo</a>

But this attribute is not currently supported on IE. And it just opens a new tab with the image on IE (Because it's a known file extension)

Is there any way to force the download of an image file just using html and without zipping it or any other method of this kind?

Please don't indicate javascript libraries.

user1383093
  • 89
  • 1
  • 2
  • 12

3 Answers3

0

I think you will not get far without JS.

Microsoft supports this tag from the Edge browser. Do you really need it for older versions?

Daniel
  • 126
  • 2
  • 5
  • Yes it's mandatory to support old IE versions >= IE 9. Do you've any simple javascript solution without using a library? – user1383093 Dec 28 '16 at 14:26
0

I just read something else. You can try to fill the download attributes with a filename, so:

... download="sample.png" ...
Daniel
  • 126
  • 2
  • 5
0

I found this Codesnippet (force browser to download image files on click):

var link = document.createElement('a');
link.href = 'images.jpg';
link.download = 'sample.jpg';
document.body.appendChild(link);
link.click();

But I´m not sure, if this is correct...

Community
  • 1
  • 1
Daniel
  • 126
  • 2
  • 5
  • It's the same I suggested but in this case you're creating the link element with javascript instead of using html. So it doesn't work in IE. – user1383093 Dec 28 '16 at 17:07