1

我有一个电话间隙/cordova 应用程序。我有一个包含链接、2 个文本字段和文本的视图。

我想从网络视图中删除复制、粘贴和选择选项。

使用:

[webView stringByEvaluatingJavaScriptFromString:@"document.body.style.webkitTouchCallout='none';"];

[webView stringByEvaluatingJavaScriptFromString:@"document.body.style.webkitUserSelect='none';"];

我能够禁用复制粘贴并从网络视图中选择菜单,但它仍然在输入字段中徘徊,即文本字段。

我尝试的是禁用 webview 上的长按,禁用放大镜并因此禁用复制和粘贴菜单,但是当我们双击文本字段时菜单也会出现。如何禁用 webview 上的长按和双击?

如果我禁用放大镜,我的应用程序是否会清除应用程序商店的审核过程,我有点困惑。

请帮我解决这个问题。

4

3 回答 3

3

我认为这已在其他地方讨论过,但最终对我有用的是在 css 中添加以下内容。

/******************
disable select touch and hold and highlight colors
******************/
html {
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color:rgba(0,0,0,0);
}

如果您仍然希望它可以用于输入,那么我添加了

input {
    -webkit-user-select: auto !important;
    -webkit-touch-callout: default !important;
}

感谢Phonegap 样式 -webkit-user-select: none; 禁用文本字段

于 2013-10-23T13:37:05.793 回答
0
 Use this.
 <style type="text/css">
 *:not(input):not(textarea) {
   -webkit-user-select: none; /* disable selection/Copy of UIWebView */
   -webkit-touch-callout: none; /* disable the IOS popup when long-press on a link */
  }       
 </style>
 If you want Disable only anchor button tag use this.

 a {-webkit-user-select: none; /* disable selection/Copy of UIWebView */
    -webkit-touch-callout: none; /* disable the IOS popup when long-press on a link */
 }
于 2014-08-21T10:03:28.217 回答
0

我想知道您为什么要删除复制和粘贴功能:安全问题?如果您想在您的应用程序中保留文本选择和复制粘贴,但您想阻止人们将您的内容复制并粘贴到其他应用程序,请查看 Cordova 插件cordova-disable-copy-paste

于 2017-05-04T13:08:01.273 回答