Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trigger touch callout on iOS/android

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

like image 805
kindisch Avatar asked Dec 07 '16 03:12

kindisch


1 Answers

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
  }
});
like image 58
Pritish Vaidya Avatar answered Oct 19 '22 15:10

Pritish Vaidya