在Chrome中不能选择Textarea [英] Textarea not selectable in Chrome

查看:267
本文介绍了在Chrome中不能选择Textarea的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谷歌浏览器(我使用的是63.0.3239.132版本)有可能使textarea无法选择(只有内部文本无法选择)吗?
在Edge,Explorer和Firefox中,此代码可用,但不适用于Chrome。



是否还有其他样式属性需要添加?

谢谢

<!DOCTYPE html>< ; HTML> < HEAD> <风格> .mytextarea {cursor:default; -webkit-touch-callout:none; -webkit-user-select:none; -khtml-user-select:none; -moz-user-select:none; -ms-user-select:none; -webkit-user-select:none; }< / style>< / head>< body> < textarea id =objLogclass =mytextareadisabled =disabledreadonly style =background-color:#FFFFFF; width:400px; height:100px;>测试测试测试测试测试测试测试测试测试测试测试< / textarea>< / body>< / html>

h2_lin>解决方案

这也应该工作

.mytextarea :: selection {-webkit-touch-callout:none; -webkit-user-select:none; -khtml-user-select:none; -moz-user-select:none; -ms-user-select:none; user-select:none;}

< textarea class = mytextareaoncontextmenu =return falsereadonly =readonlystyle =background-color:#FFFFFF; width:400px; height:100px; color:grey>试验试验试验试验试验试验试验试验试验试验试验试验试验试验试验试验试验试验试验试验试验试验试验试验试验试验试验试验试验试验试验试验试验试验试验试验试验试验试验试验试验试验试验试验试验试验试验试验Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test


Is it possible in google Chrome (I'm using 63.0.3239.132 version) to make a textarea unselectable (Only the inside text unselectable)? In Edge, Explorer and Firefox this code works but not in Chrome.

Is there any other style properties to add?

Thanks

<!DOCTYPE html>

<html>
    
<head>
    <style>
        .mytextarea
        {
            cursor: default;
            -webkit-touch-callout: none;
            -webkit-user-select: none;
            -khtml-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
            -webkit-user-select: none;
        }
    </style>

</head>

<body>

    <textarea  id="objLog" class="mytextarea" disabled="disabled" readonly style="background-color: #FFFFFF; width:400px; height:100px;">
Test Test Test Test Test Test
Test Test Test Test Test Test
    </textarea>

</body>

</html>

解决方案

This should work too

.mytextarea::selection {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

<textarea class="mytextarea" oncontextmenu="return false" readonly="readonly" 
style="background-color: #FFFFFF; width:400px; height:100px;color:grey">
    Test Test Test Test Test Test
        Test Test Test Test Test Test
        Test Test Test Test Test Test
        Test Test Test Test Test Test
        Test Test Test Test Test Test
        Test Test Test Test Test Test
        Test Test Test Test Test Test
        Test Test Test Test Test Test
        Test Test Test Test Test Test
        Test Test Test Test Test Test
        Test Test Test Test Test Test
        Test Test Test Test Test Test
        Test Test Test Test Test Test
        Test Test Test Test Test Test
        </textarea>

这篇关于在Chrome中不能选择Textarea的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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