触发iOS上的触摸标注/ android
问题描述:
我想知道是否有可能通过Javascript在iOS和Android上触发“保存图像”触摸标注。标注由longpress触发,但即使我试图模拟这一点,它也不起作用。触发iOS上的触摸标注/ android
我想实现的东西喜欢这样的:
jQuery('img').openCallout();
到目前为止,我尝试这样做:
的jQuery:jQuery('img').contextmenu();
jQuery Mobile的:jQuery('img').taphold();
答
是的,这是可能使用的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
}
});
但在这种情况下,它只是下载图像和不显示标注在我的PI上面的? – kindisch
这是在铬下载图片没有问,但这只是一个例子,我已经附加了'a'标签,因为我没有平台在iOS设备上测试//这只是一个参考,功能起作用。 –