问题
I am trying to disable text selection and copy paste in phonegap applicaion by using following code.
CSS
-webkit-user-select:none;
JavaScript
$('body').on('cut copy paste',function(e){e.preventDefault();});
It works on all OS platforms including adroid 4.4+ but having issues on 4.1 and 4.2. Please Help.
Both doesn't support android 4.1.2 and 4.2.1.
[Tested on Micromax canvas 4 and samsung galaxy s2]
回答1:
you can use css to do that
*
{
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
input
{
-webkit-user-select: auto !important;
-khtml-user-select: auto !important;
-moz-user-select: auto !important;
-ms-user-select: auto !important;
user-select: auto !important;
}
found here Disable Copy and Paste in Phonegap
回答2:
Here is the solution I found and worked, but not through JS. Paste the following code in MainActivity.java file
super.appView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
// TODO Auto-generated method stub
return true;
}
});
来源:https://stackoverflow.com/questions/27615891/disable-text-selection-and-copy-paste-in-hybrid-app-using-js