Is it possible to disable text selection to make a PhoneGap app more similar to normal native app?
Something like this:
Add this and enjoy. Works on iOS as well.
<style type="text/css">
*:not(input,textarea) {
-webkit-touch-callout: none;
-webkit-user-select: none; /* Disable selection/Copy of UIWebView */
}
</style>
I used below code and its working fine on Android and iOS devices as well as on emulator/simulator:
* {
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
input, textarea {
-webkit-user-select: auto !important;
-khtml-user-select: auto !important;
-moz-user-select: auto !important;
-ms-user-select: auto !important;
user-select: auto !important;
}
As well as what ThinkingStiff mentioned I also use the following to remove any highlighting/copy & paste
-webkit-touch-callout: none;
-webkit-tap-highlight-color: rgba(0,0,0,0);
* {
-webkit-touch-callout: none;
-webkit-user-select: none;
}
[contenteditable="true"] , input, textarea {
-webkit-user-select: auto !important;
-khtml-user-select: auto !important;
-moz-user-select: auto !important;
-ms-user-select: auto !important;
-o-user-select: auto !important;
user-select: auto !important;
}
this will work too.
<body oncontextmenu="return false" ondragstart="return false"
onselectstart="return false">
Putting it on html
, not *
, works for me:
html {
-webkit-user-select: none;
}