防止Android“长按”保存图像
我用 HTML 和 Javascript 为 iPhone 和 Android 编写了一个网络应用程序,其中涉及拖放图像。
您可以通过将手指放在图像上大约一秒钟来启动拖动。然而,Android 然后会弹出一条消息,让我选择保存图像、将其设置为壁纸等。
我怎样才能阻止 Android 这样做呢?有我可以使用的元标记吗?一些 JavaScript?
I've written a web-app in HTML and Javascript for iPhone and Android which involves the dragging and dropping images.
You initiate the drag by holding your finger over the image for about a second. However, Android then pops up the message giving me the option to save the image, set it as wallpaper etc.
How can I prevent Android from doing this? Is there a metatag I can use? Some javascript?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用此事件:
Use this event:
JavaScript 具有防止浏览器对相关事件执行默认操作的功能。
在您的 javascript 中尝试:
请参阅: https://developer.mozilla.org/en/DOM /event.preventDefault
Javascript has a function to prevent the default action of a browser for the event in question.
In your javascript try:
See: https://developer.mozilla.org/en/DOM/event.preventDefault
在显示 Web 视图的 Activity 中,尝试扩展
GestureDetector.SimpleOnGestureListener
。然后重写 onLongPress(MotionEvent e) 方法并且不执行任何操作。如果这不起作用,您可能必须创建一个继承自 webview 的自定义 webview 并在那里覆盖 onLongPress。
或者也许你可以尝试
In your activity that shows the webview, try extending
GestureDetector.SimpleOnGestureListener
. Then override theonLongPress(MotionEvent e)
method and doing nothing.If that doesn't work, you might have to create a custom webview that inherets from webview and overrides onLongPress there.
Or maybe you could try