javascript - 在 iOS/android 上触发触摸标注

标签 javascript android ios web callout

我想知道是否有可能使用 Javascript 在 iOS 和 Android 上触发“保存图像”触摸标注。标注由长按触发,但即使我尝试模拟它,它也不会起作用。

我想实现这样的目标:

jQuery('img').openCallout();

到目前为止我试过这个:

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

enter image description here

最佳答案

是的,可能的,使用 jquery mobile,如 docs 中所述, 使用 taphold事件。(其他事件,我没试过)

如本 fiddle 所示(目前测试如下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
  }
});

关于javascript - 在 iOS/android 上触发触摸标注,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41008693/

相关文章:

javascript - 如何在网页中从 mandrillapp 隐藏我的私钥

javascript - 如何让机器人提及 channel ?

android - 使用 startInstrumentation() 启动 Instrumentation 时 UiDevice.getInstance(getInstrumentation()) 崩溃(作为空对象引用)

c# - 如何使用 visual studio 和 xamarin 关闭 android Activity

android - android中的文档可视化?

ios - 如何在任何 Facebook 帐户上分享图像?

node.js - 如何从远程服务器下载一堆文件,并使用 Node.js 按特定顺序连接它们?

javascript - Angular js + Rails 好主意吗?

iOS - 是否可以在 iOS 中以编程方式将 UIImage 与 WhatsApp 共享?

ios - 根据与其他位置的距离计算位置