HTML:光标显示在只读输入文本中? [英] HTML: cursor showing in readonly input text?
问题描述
假设我们有一个只读的文本框,如下所示:
Let's say we have a textbox that's readonly, like so:
<input type="text" readonly />
在 IE 9 和 FF 4 中,当我单击该字段时,该字段中会出现一个(不闪烁)光标.但是,在 Chrome 中,光标不显示.(请参阅 http://jsfiddle.net/hqBsW/.)
In IE 9 and FF 4, when I click on this field, a (non-blinking) cursor appears in the field. In Chrome, however, the cursor does not show. (See for yourself at http://jsfiddle.net/hqBsW/.)
我想我明白为什么 IE/FF 选择显示光标——这样用户就知道他或她仍然可以选择字段中的值.
I suppose I understand why IE/FF opt to show the cursor—so the user knows he or she can still select the value in the field.
尽管如此,这显然让我们的用户感到困惑,我们希望将 IE/FF 更改为不显示光标,就像 Chrome 对 readonly
字段所做的那样.
Nonetheless, it's evidently confusing our users and we would like to change IE/FF to not show the cursor, as Chrome does for readonly
fields.
有没有办法做到这一点?
Is there a way to do this?
推荐答案
听起来像个错误!
Mozilla 打开了一个一个类似的错误 (396542),说光标应该在 readonly
输入中闪烁——但这种行为感觉不对,闪烁的光标应该表示你可以在这里输入."
There is a similar bug (396542) open with Mozilla, saying that the cursor should blink in readonly
inputs — but that behavior feels wrong, a blinking cursor is supposed to mean, "you can type here."
您应该对该错误发表评论和/或提交新的错误(使用 Mozilla 此处 并使用Microsoft 此处)!
You should comment on that bug and/or file new ones (with Mozilla here and with Microsoft here)!
与此同时,如@nikmd23 建议的那样,使用 disabled
或使用 JavaScript 更改行为似乎是最好的解决方法.
In the meantime, using disabled
or changing the behavior with JavaScript, as @nikmd23 suggested, seems like the best workaround.
这篇关于HTML:光标显示在只读输入文本中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!