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