我想禁用当您在图像上按住手指时出现的移动Web应用程序中的"保存图像"菜单.我尝试了CSS属性:
-webkit-user-select: none;
-webkit-touch-callout: none;
Run Code Online (Sandbox Code Playgroud)
使用"-webkit-user-select"复制菜单被禁用,但不能用于保存图像."-webkit-touch-callout"似乎不起作用(在iPad2上试过).
我也试过这个javascript:
$('img').live('touchstart,touchmove,touchend', function() {
event.preventDefault();
});
Run Code Online (Sandbox Code Playgroud)
但没有任何影响.
有什么建议?提前致谢!
我不明白如何使用event.touches属性.例如,要获得iPad/iPhone上的手指数量,您应该使用
event.touches.length
Run Code Online (Sandbox Code Playgroud)
那为什么这个示例代码不起作用?
$('.image').bind('touchstart', function(event) {
alert(event.touches.length);
});
Run Code Online (Sandbox Code Playgroud)
但这有效:
$('.image').bind('touchstart', function() {
alert(event.touches.length);
});
Run Code Online (Sandbox Code Playgroud)
不应该反过来吗?