admin管理员组文章数量:1334384
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?
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?
Share Improve this question asked Aug 13, 2010 at 21:15 user385990user385990 1211 silver badge5 bronze badges3 Answers
Reset to default 3Use this event:
$(document).on('contextmenu', function (e) {
// stop long touch hold from poping up context menus
return false;
});
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/en/DOM/event.preventDefault
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)
本文标签: javascriptPreventing the Android quotlong pressquot to save imagesStack Overflow
版权声明:本文标题:javascript - Preventing the Android "long press" to save images - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742242273a2438908.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论