禁止IOS 默认的长按复制-H5

转载自https://www.cnblogs.com/sz-xioabai/p/9765471.html
场景:H5长按事件,需要禁止IOS默认的长按复制。
注意:增加之后需要对input的另外设置,不然输入框无法输入

ios机默认存在长按复制选择,用以下代码取消:

*{
  -webkit-touch-callout:none; /*系统默认菜单被禁用*/
  -webkit-user-select:none; /*webkit浏览器*/
  -khtml-user-select:none; /*早期浏览器*/
  -moz-user-select:none;/*火狐*/
  -ms-user-select:none; /*IE10*/
  user-select:none;
}

但是以上代码也会禁止输入框的使用,可用以下代码解决:

input {
  -webkit-user-select:auto; /*webkit浏览器*/
}
 //如果存在textarea也输入不进文本的情况下,加上这个
textarea {                                                               
  -webkit-user-select:auto; /*webkit浏览器*/
}

你可能感兴趣的:(禁止IOS 默认的长按复制-H5)