防止在 iOS Web 应用程序中复制图像
有没有办法阻止在 iPad 或 iPhone Web 应用程序上的图像上按住手指时出现菜单。我正在创建一个遥控器,并使用 ontouchstart 和 ontouchend 内置函数来创建我实现的“ontouchhold”函数。该函数使用 ontouchstart 和 ontouchend 内置函数通过我的计算机发送红外信号,该计算机充当服务器,同时用户将手指按住图像(ontouchend 函数将清除间隔)。唯一的问题是,如果用户长时间按住手指,那么我实现的 javaScript 函数 ontouchhold 将停止工作,因为会弹出一个菜单,询问用户是否要复制/保存图像。如果我能阻止这个菜单出现就好了。
Is there a way of preventing the menu that appears when you hold down a finger on an image on an iPad or iPhone web application. I am creating a remote control and I use the ontouchstart and ontouchend built in functions to create my "ontouchhold" function that I implemented. That function uses the ontouchstart and ontouchend built in functions to send IR signals via my computer which is acting as the server meanwhile the user is holding down its finger against an image (the ontouchend function will clear the interval). The only problem is that if the user holds its finger to long then the javaScript function ontouchhold that I implemented stops working because a menu pops up asking the user if he wants to copy/save the image. It will be nice if I could prevent this menu from appearing.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以使用:
此属性使 html 元素不是不可选择的,从而防止 iphone 的复制行为
You can use:
This property makes the html elements not be not selectable and thus prevents that copy behaviour of iphone
-webkit-touch-callout: none;
似乎只阻止复制/保存对话框打开而不禁用任何其他事件。pointer-events: none;
还将阻止复制/保存对话框,但也会阻止附加到图像的任何其他相关事件-webkit-touch-callout: none;
seems to do the trick of only preventing the copy/save dialog from opening without disabling any other events.pointer-events: none;
will also prevent the copy/save dialog but will also prevent any other dependent events attached to the image您可以添加
preventDefault()
到元素,这会阻止复制菜单:但它也会阻止在滑动事件开始时滚动这个元素。
You can add a
preventDefault()
to the element, which prevents the copy menu:But it also prevents the scrolling when the swipe event was started on this element.
我不知道iOS或手机:但是如果你将图像设为背景图像,它通常不会给你保存的选项......
I don't know about iOS or mobile phones: but if you make the image a background image, it doesn't usually give you the option to save .....