简体   繁体   English

Android Webkit中的只读输入不起作用

[英]Read-only input in Android Webkit not working

I have a text input field in my web page that I am using to collect a date (via the jQuery Tools .dateinput). 我的网页上有一个文本输入字段,我正在使用它来收集日期(通过jQuery Tools .dateinput)。 The user does not need to be able to type into the field. 用户不需要能够在该字段中键入。 A dialog box appears when the field is clicked on. 单击该字段时,将出现一个对话框。 This is a problem on my Motorola Droid, because I don't want the soft-keyboard to appear when the field is clicked. 这是我的Motorola Droid上的问题,因为我不希望在单击该字段时显示软键盘。

I have tried input.blur() on focus and also setting the field to disabled and readonly. 我已经尝试过将input.blur()放在焦点上,并且还将字段设置为禁用和只读。 Setting the field to disabled has undesired side effects. 将字段设置为禁用会产生不希望的副作用。 Setting the field to readonly works in everything but the Android browser. 将字段设置为只读仅适用于Android浏览器。 The browser seems to recognized the "readonly" attribute (or readOnly via javascript), BUT the field does not actually become readonly. 浏览器似乎识别出“ readonly”属性(或通过javascript只读),但该字段实际上并未变为只读。 When you click it, the soft keyboard still appears and allows you to change the field. 当您单击它时,软键盘仍会出现,并允许您更改该字段。

I suppose that this is a bug in the Android browser. 我想这是Android浏览器中的错误。 Can anyone come up with a clever alternative? 谁能提出一个聪明的选择?

I used a workaround - since I didn't need to actually edit in the input field (like you, I was popping a date picker), I changed to a span with similar styling. 我使用了一种解决方法-由于不需要实际在输入字段中进行编辑(就像您一样,我正在弹出日期选择器),因此我更改为具有类似样式的跨度。 The code is kind of trivial once you have the trick, and it's really app specific so I don't have any really for you to see. 一旦掌握了技巧,该代码就变得微不足道了,它确实是特定于应用程序的,因此我没有任何真正的可看之处。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM