我想知道是否有可能使用 Javascript 在 iOS 和 Android 上触发“保存图像”触摸标注。标注是由长按触发的,但即使我尝试模拟它,它也不起作用。
我想实现这样的目标:
jQuery('img').openCallout();
到目前为止,我试过这个:
jQuery: jQuery('img').contextmenu();
jQuery 移动: jQuery('img').taphold();
我想知道是否有可能使用 Javascript 在 iOS 和 Android 上触发“保存图像”触摸标注。标注是由长按触发的,但即使我尝试模拟它,它也不起作用。
我想实现这样的目标:
jQuery('img').openCallout();
到目前为止,我试过这个:
jQuery: jQuery('img').contextmenu();
jQuery 移动: jQuery('img').taphold();
是的,这可以使用文档中jquery mobile
提到的,使用taphold事件。(其他事件,我没有尝试)
如this 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
}
});