使用JS在混合应用程序中禁用文本选择和复制粘贴 [英] Disable text selection and copy paste in hybrid app using JS

查看:75
本文介绍了使用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中禁用复制和粘贴

这篇关于使用JS在混合应用程序中禁用文本选择和复制粘贴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆