Text selection in WebView
How to disable the webview context menu (copy and define) while enabling text selection?
I have tried different combination of css property. Seems the context menu can only be disabled with the following combination:
-webkit-touch-callout:none;
-webkit-user-select:none;
If set -webkit-user-select to "text", the callout is enabled even -webkit-touch-callout is set to "none"
I just need the text highlight behavior but not the "copy" popover menu in browser.
Anyone has a clue?
P.S. I am testing my app on iPad simulator and device.
3 Answers
-
did you manage to find answer for this? i am also looking to solve the same problem. please let me know.
-
use this—–>
webview.addEventListener('longpress', function(e) {
return false;
});webview.addEventListener('longclick', function(e) {
return false;
}); -
yes i am sure this will help you for only android and for iphone you can add this css ——>
- {
-webkit-touch-callout: none;
-webkit-user-select: none; / Disable selection/Copy of UIWebView /
}
- {