防止Android“长按”保存图像

发布于 2024-09-14 15:10:15 字数 196 浏览 3 评论 0原文

我用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

彼岸花似海 2024-09-21 15:10:15

使用此事件:

            $(document).on('contextmenu', function (e) {
                // stop long touch hold from poping up context menus
                return false;
            });

Use this event:

            $(document).on('contextmenu', function (e) {
                // stop long touch hold from poping up context menus
                return false;
            });
能否归途做我良人 2024-09-21 15:10:15

JavaScript 具有防止浏览器对相关事件执行默认操作的功能。

在您的 javascript 中尝试:

event.preventDefault();

请参阅: 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:

event.preventDefault();

See: https://developer.mozilla.org/en/DOM/event.preventDefault

静赏你的温柔 2024-09-21 15:10:15

在显示 Web 视图的 Activity 中,尝试扩展 GestureDetector.SimpleOnGestureListener。然后重写 onLongPress(MotionEvent e) 方法并且不执行任何操作。

如果这不起作用,您可能必须创建一个继承自 webview 的自定义 webview 并在那里覆盖 onLongPress。

或者也许你可以尝试


WebView wv =(WebView) findViewById()
wv.setClickable(false)

In your activity that shows the webview, try extending GestureDetector.SimpleOnGestureListener. Then override the onLongPress(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


WebView wv =(WebView) findViewById()
wv.setClickable(false)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文