7

I would like to know if there is any possibility to trigger the "Save Image" touch callout on iOS and Android with Javascript. The callout is triggered by a longpress, but even if I try to simulate this, it won't work.

I would like to achieve something likes this:

jQuery('img').openCallout();

So far I tried this:

jQuery: jQuery('img').contextmenu();
jQuery Mobile: jQuery('img').taphold();

enter image description here

Community
  • 1
  • 1
kindisch
  • 766
  • 1
  • 7
  • 23

1 Answers1

2

Yes ,this is possible using the jquery mobile as mentioned in the docs,using the taphold event.(Other events, I didn't try)

As illustrated in this fiddle (Till now tested in the following as shown here)

$(function() {
  $("div.box").bind("taphold", tapholdHandler);

  function tapholdHandler(event) {
    alert('Do you want to save the image or however it works in ipad');
    var a = document.createElement('a');
    a.href = "http://i.imgur.com/JzdY53y.jpg";
    a.download = 'JzdY53y.jpg';
    alert("goes till here1"); // just a check
    a.click();
    alert("goes til here 2"); //just a check
  }
});
Pritish Vaidya
  • 21,561
  • 3
  • 58
  • 76
  • But in this case it just downloads the image and doesn't show the callout as in my picture above? – kindisch Dec 19 '16 at 12:45
  • yea in chrome it downloads the picture without asking but this is just an example in which i have appended the `a` tag since i have no platform to test in the ios device.//This is justa reference to the fact that the taphold function works. – Pritish Vaidya Dec 19 '16 at 13:15