HTML:显示只读输入文本的光标? [英] HTML: cursor showing in readonly input text?

查看:108
本文介绍了HTML:显示只读输入文本的光标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



 < input type =textreadonly /> ; 

在IE 9和FF 4中,当我点击此字段时,(非闪烁)游标出现在现场。但是,在Chrome中,光标不显示。 (请参阅 http://jsfiddle.net/hqBsW/ 。)



我想我明白为什么IE / FF选择显示光标 - 所以用户知道他或她仍然可以选择该字段中的值。尽管如此,它显然让我们的用户感到困惑,并且我们希望将IE / FF改为不显示游标,正如Chrome针对 readonly 所做的那样 code>字段。



有没有办法做到这一点?

解决方案听起来像一个bug!



一个类似的bug(396542)用Mozilla打开,表示光标应在 readonly 输入中闪烁 - 但是这种行为感觉不对,一个闪烁的光标应该是这个意思,你可以在这里输入。



你应该评论这个错误和/或提交新的错误Mozilla 此处和Microsoft

在此期间,使用禁用或更改正如@ n​​ikmd23所建议的,JavaScript的行为,似乎是最好的解决方法。


Let's say we have a textbox that's readonly, like so:

<input type="text" readonly />

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/.)

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.

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?

解决方案

Sounds like a bug!

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."

You should comment on that bug and/or file new ones (with Mozilla here and with Microsoft here)!

In the meantime, using disabled or changing the behavior with JavaScript, as @nikmd23 suggested, seems like the best workaround.

这篇关于HTML:显示只读输入文本的光标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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