【问题标题】:why the attribute contentEditable of input text box does not work in Chrome?为什么输入文本框的属性 contentEditable 在 Chrome 中不起作用?
【发布时间】:2012-03-26 03:25:32
【问题描述】:

在我的 .net 项目中,有很多这样的代码

< asp:TextBox ID="txtDeparment" runat="server" contentEditable="false">< /asp:TextBox>

它在 IE 中运行良好,但在 Chrome 中,它不起作用。但您不能简单地将其替换为 ReadOnly。

我怎样才能以最少的改动解决这个问题?

【问题讨论】:

  • 您使用服务器端文本框而不是 &lt;input type='text'&gt; 是否有特殊原因?

标签: google-chrome input textbox contenteditable


【解决方案1】:

为了使文本框不可编辑,您应该使用以下 CSS 属性:

user-select: none;
-webkit-user-select: none;
-moz-user-select: none;

这些 CSS 属性不允许选择元素,在输入字段的情况下,也拒绝编辑它。

【讨论】:

  • 正如您已经说过的,CSS 将阻止用户选择输入的内容,但问题是关于如何防止编辑 i> 在 Chrome 中。
猜你喜欢
  • 2020-02-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-03-15
  • 2018-08-15
  • 2020-11-20
  • 2018-10-31
  • 1970-01-01
相关资源
最近更新 更多