1

I need to add a download button to an image in a website that is a mobile site. I looked other related questions and all of that are for PC browsers. I need an answer to support mobile browsers.

I used HTML <a> download Attribute

But it's not supported in mobile browsers.

Lahiru Jayaratne
  • 1,684
  • 4
  • 31
  • 35
Lahiru Madusanka
  • 270
  • 2
  • 13
  • Possible duplicate of [onClick not working on mobile (touch)](http://stackoverflow.com/questions/22015908/onclick-not-working-on-mobile-touch) – demo Jan 11 '17 at 10:29

2 Answers2

0

You can use this

<a href="/path/to/image" download="myimage"><img src="/path/to/image" /></a>
shahzeb akram
  • 906
  • 7
  • 24
  • 1
    I tried this one as i informed in my question. i need a code that support in a mobile browsers. your code working in computer browsers. – Lahiru Madusanka Jan 20 '17 at 05:16
0

You Can use Jquery if Html Failed.....Html Code

 <div id="imageDiv"><img src="ImageLink" style="margin-top: 0px;"></div>
 <a href="#" onclick="Download_Image(this)" download>Click here to download image</a>

Jquery

<script>
   function Download_Image(element)
   {
     debugger;
     var mydiv =$("#imageDiv");
     var Image=mydiv[0].children;
     mydiv.download=Image[0].src;
   }
</script>
Ghanshyam Singh
  • 1,361
  • 2
  • 15
  • 27