Disable text selection and copy to hybrid application using JS

I am trying to disable text selection and copy phonegap to the application using the 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 problems with 4.1 and 4.2. Please, help.

Both do not support android 4.1.2 and 4.2.1.

[Tested on Micromax 4 canvas and samsung s2 galaxy]

+5
source share
2 answers

you can use css for this

 * { -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 copying and pasting into Phonegap

+14
source

Here is a solution that I found and worked, but not through JS. Paste the following code into the MainActivity.java file

 super.appView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { // TODO Auto-generated method stub return true; } }); 
0
source

Source: https://habr.com/ru/post/1209754/


All Articles