Chrome尽管使用“-webkit-user-select:none”来复制文本。 [英] Chrome copies text despite using "-webkit-user-select: none"

查看:121
本文介绍了Chrome尽管使用“-webkit-user-select:none”来复制文本。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在表格中创建一个不可复制的元素(因为有更好的可读性)。

在Firefox中,它工作正常。如果您选择所有内容并将其复制,则特定的文本元素不会被复制。



很遗憾,在Chrome中这不起作用。

 < td unselectable =onid =unselectable > Test2的< / TD> 

#unselectable {
-webkit-touch-callout:none;
-webkit-user-select:none;
-khtml-user-select:none;
-moz-user-select:none;
-ms-user-select:none;
user-select:none;
}

示例: http://jsfiddle.net/pXAeB/



有没有解决这个问题的方法?

解决方案

Demo Fiddle a>



将以下内容添加到您的表格元素中:

 取消选择='on'
onselectstart ='return false;'
onmousedown ='return false;'

到你的表格元素。请注意,对于Chrome,大多数时候只需包含 onselectstart ='return false;'就足够了。


I want to create an element within a table which is not copyable (because of better readability).

In Firefox it is working correctly. If you select everything and copy it, the specific text element is not beeing copied.

Sadly in Chrome this doesn't work. Indeed the browser does not select the text, but copies it.

<td unselectable="on" id="unselectable">Test2</td>

#unselectable {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

Example: http://jsfiddle.net/pXAeB/

Is there a solution to this problem?

解决方案

Demo Fiddle

Add the below to your table element:

unselectable='on'
onselectstart='return false;' 
onmousedown='return false;'

To your table element. Note that for Chrome, most of the time just the inclusion of onselectstart='return false;' should suffice.

这篇关于Chrome尽管使用“-webkit-user-select:none”来复制文本。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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