使用JS在混合应用程序中禁用文本选择和复制粘贴

问题描述:

我试图通过使用以下代码来禁用文本选择并在phonegap应用程序中复制粘贴.

I am trying to disable text selection and copy paste in phonegap applicaion by using following code.

CSS

-webkit-user-select:none;

JavaScript

JavaScript

$('body').on('cut copy paste',function(e){e.preventDefault();});

它可在所有操作系统平台(包括adroid 4.4+)上运行,但在4.1和4.2上存在问题.请帮忙.

It works on all OS platforms including adroid 4.4+ but having issues on 4.1 and 4.2. Please Help.

两者都不支持android 4.1.2和4.2.1.

Both doesn't support android 4.1.2 and 4.2.1.

[在Micromax canvas 4和三星银河s2上测试]

[Tested on Micromax canvas 4 and samsung galaxy s2]

您可以使用CSS做到这一点

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;
}

在此处找到在Phonegap中禁用复制和粘贴