简体   繁体   中英

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();

在此输入图像描述

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
  }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM