【问题标题】:Trigger touch callout on iOS/android在 iOS/android 上触发触摸标注
【发布时间】:2017-04-21 21:05:42
【问题描述】:

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

我想实现这样的目标:

jQuery('img').openCallout();

到目前为止,我尝试过这个:

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

【问题讨论】:

    标签: javascript android ios web callout


    【解决方案1】:

    是的,这个是可能使用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
      }
    });
    

    【讨论】:

    • 但在这种情况下,它只是下载图像,并没有像我上面的图片那样显示标注?
    • 是的,在 chrome 中它会在不询问的情况下下载图片,但这只是一个示例,我在其中附加了 a 标签,因为我没有在 ios 设备中测试的平台。//这只是参考 taphold 功能有效的事实。
    猜你喜欢
    • 1970-01-01
    • 2019-05-09
    • 1970-01-01
    • 2021-03-18
    • 2013-04-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多